diff --git a/box.json b/box.json index 790fe37fd..eb2b6cf72 100644 --- a/box.json +++ b/box.json @@ -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", diff --git a/system/services/formbuilder/FormBuilderService.cfc b/system/services/formbuilder/FormBuilderService.cfc index b443663dd..48cb0a61a 100644 --- a/system/services/formbuilder/FormBuilderService.cfc +++ b/system/services/formbuilder/FormBuilderService.cfc @@ -1607,7 +1607,6 @@ component { itemsToRender.append( formItems[i] ); itemColumnMap[ formItems[ i ].id ] = columns; headers.append( columns, true ); - } } } @@ -1616,13 +1615,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" ); @@ -1648,10 +1649,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++; } } } @@ -1672,6 +1681,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++ ){