From 12712f80a94443c7171272705123e2a058fe26e4 Mon Sep 17 00:00:00 2001 From: Teon Ooi Date: Fri, 20 Dec 2024 15:51:36 +0800 Subject: [PATCH 1/4] [twgit] Init feature 'feature-PRESIDECMS-2956_formbuilder-form-export-error-when-response-exceed--32767-characters'. From 2ba21a8db59a8108fabd7232c7b29de24037d89a Mon Sep 17 00:00:00 2001 From: Teon Ooi Date: Fri, 20 Dec 2024 15:52:31 +0800 Subject: [PATCH 2/4] PRESIDECMS-2956 Update to split and add extra column if exceed characters limit. --- .../formbuilder/FormBuilderService.cfc | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/system/services/formbuilder/FormBuilderService.cfc b/system/services/formbuilder/FormBuilderService.cfc index 65693b6cb..3153057c8 100644 --- a/system/services/formbuilder/FormBuilderService.cfc +++ b/system/services/formbuilder/FormBuilderService.cfc @@ -1599,7 +1599,6 @@ component { itemsToRender.append( formItems[i] ); itemColumnMap[ formItems[ i ].id ] = columns; headers.append( columns, true ); - } } } @@ -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" ); @@ -1639,10 +1640,18 @@ component { var mappedColumns = itemColumnMap[ item.id ]; for( var i=1; i<=mappedColumns.len(); i++ ) { + ++column; + 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 ); } } } @@ -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++ ){ From fb90675b572bfb91a64d17291d542b5b37c1b7a5 Mon Sep 17 00:00:00 2001 From: Teon Ooi Date: Fri, 20 Dec 2024 15:53:30 +0800 Subject: [PATCH 3/4] PRESIDECMS-2956 Update lucee spreadsheet version. --- box.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From 13f2ec9c5b8fb84e6aeef120cd94ac55275ce0b4 Mon Sep 17 00:00:00 2001 From: Teon Ooi Date: Thu, 26 Dec 2024 10:21:06 +0800 Subject: [PATCH 4/4] PRESIDECMS-2956 Update increment consistency. --- system/services/formbuilder/FormBuilderService.cfc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/services/formbuilder/FormBuilderService.cfc b/system/services/formbuilder/FormBuilderService.cfc index 3153057c8..eb65b7207 100644 --- a/system/services/formbuilder/FormBuilderService.cfc +++ b/system/services/formbuilder/FormBuilderService.cfc @@ -1615,7 +1615,7 @@ component { var extraCols = {}; var row = 1; for ( var submission in submissions ) { - var column = 4; + 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" ); @@ -1640,8 +1640,6 @@ component { var mappedColumns = itemColumnMap[ item.id ]; for( var i=1; i<=mappedColumns.len(); i++ ) { - ++column; - if ( itemColumns.len() >= i ) { if ( Len( itemColumns[ i ] ) >= 32767 ) { extraCols[ column ][ row ] = Mid( itemColumns[ i ], 32768 ); @@ -1653,6 +1651,8 @@ component { } else { spreadsheetLib.setCellValue( workbook, "", row, column ); } + + column++; } } }