Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRESIDECMS-2956 Formbuilder form export error when response exceed 32767 characters #1559

Open
wants to merge 4 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
34 changes: 28 additions & 6 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,12 +1607,14 @@ 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 extraCols = {};
var row = 1;
for ( var submission in submissions ) {
var column = 4;
row++;
spreadsheetLib.setCellValue( workbook, submission.id, row, 1, "string" );
Expand All @@ -1639,10 +1640,18 @@ component {
var mappedColumns = itemColumnMap[ item.id ];

for( var i=1; i<=mappedColumns.len(); i++ ) {
++column;
teonator marked this conversation as resolved.
Show resolved Hide resolved

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 );
}
}
}
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
Loading