diff --git a/src/pages/api/assignments/[id]/[export]/excel.ts b/src/pages/api/assignments/[id]/[export]/excel.ts index bf19569e..d4fa7f05 100644 --- a/src/pages/api/assignments/[id]/[export]/excel.ts +++ b/src/pages/api/assignments/[id]/[export]/excel.ts @@ -195,12 +195,16 @@ function commonExcel({ // K10:M12 = 10,11,12,13 // horizontally group Test Sections - worksheet.mergeCells( - startIndexTable, - staticHeaders.length + 1, - startIndexTable, - tableColumnHeadersFirstPart.length - ); + + // if there are test section headers to even merge: + if(testSectionHeaders.length > 1) { + worksheet.mergeCells( + startIndexTable, + staticHeaders.length + 1, + startIndexTable, + tableColumnHeadersFirstPart.length + ); + } // Add the dynamic second and third header rows for test sections and sub-columns worksheet.addRow([