Skip to content

Commit

Permalink
Merge branch 'feature-PRESIDECMS-2956_formbuilder-form-export-error-w…
Browse files Browse the repository at this point in the history
…hen-response-exceed--32767-characters' into hotfix-10.27.28
  • Loading branch information
DominicWatson committed Jan 6, 2025
2 parents d6a8fb8 + 13f2ec9 commit 2e5aad9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
],
"dependencies":{
"sticker":"1.3.3",
"lucee-spreadsheet":"2.12.0",
"lucee-spreadsheet":"3.0.0",
"presidecmseditor":"github:pixl8/Preside-Editor#4.17.1",
"cbi18n":"1.3.1+56",
"cbmessagebox":"2.2.0+10",
Expand Down
36 changes: 29 additions & 7 deletions system/services/formbuilder/FormBuilderService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,6 @@ component {
itemsToRender.append( formItems[i] );
itemColumnMap[ formItems[ i ].id ] = columns;
headers.append( columns, true );

}
}
}
Expand All @@ -1608,13 +1607,15 @@ component {
headers.append( "User agent" );

spreadsheetLib.renameSheet( workbook, $translateResource( uri="formbuilder:spreadsheet.main.sheet.title", data=[ formDefinition.name ] ), 1 );
for( var i=1; i <= headers.len(); i++ ){

for ( var i=1; i <= headers.len(); i++ ) {
spreadsheetLib.setCellValue( workbook, headers[i], 1, i, "string" );
}

var row = 1;
for( var submission in submissions ) {
var column = 4;
var extraCols = {};
var row = 1;
for ( var submission in submissions ) {
var column = 5;
row++;
spreadsheetLib.setCellValue( workbook, submission.id, row, 1, "string" );
spreadsheetLib.setCellValue( workbook, DateTimeFormat( submission.datecreated, "yyyy-mm-dd HH:nn:ss" ), row, 2, "string" );
Expand All @@ -1640,10 +1641,18 @@ component {

for( var i=1; i<=mappedColumns.len(); i++ ) {
if ( itemColumns.len() >= i ) {
spreadsheetLib.setCellValue( workbook, itemColumns[ i ], row, ++column, "string" );
if ( Len( itemColumns[ i ] ) >= 32767 ) {
extraCols[ column ][ row ] = Mid( itemColumns[ i ], 32768 );

spreadsheetLib.setCellValue( workbook, Left( itemColumns[ i ], 32767 ), row, column, "string" );
} else {
spreadsheetLib.setCellValue( workbook, itemColumns[ i ], row, column, "string" );
}
} else {
spreadsheetLib.setCellValue( workbook, "", row, ++column );
spreadsheetLib.setCellValue( workbook, "", row, column );
}

column++;
}
}
}
Expand All @@ -1664,6 +1673,19 @@ component {
}
}

if ( StructCount( extraCols ) ) {
for ( var col in extraCols ) {
var data = [ "" ];

for ( var row=1; row<=submissions.recordCount; row++ ) {
ArrayAppend( data, extraCols[ col ][ row + 1 ] ?: "" );
}

spreadsheetLib.addColumn( workbook=workbook, data=data, startColumn=Val( col ) + 1, insert=true );
}
}


spreadsheetLib.formatRow( workbook, { bold=true }, 1 );
spreadsheetLib.addFreezePane( workbook, 0, 1 );
for( var i=1; i <= headers.len(); i++ ){
Expand Down

0 comments on commit 2e5aad9

Please sign in to comment.