@@ -74,7 +74,10 @@ interface SheetData {
7474 tables : {
7575 title : string ;
7676 startCell : string ;
77- rows : any [ ] [ ] ;
77+ rows : {
78+ type : string ; // static_value or formula,
79+ value : string ;
80+ } [ ] [ ] ;
7881 columns : { name : string ; type : string ; format : string } [ ] ; // types that have format, number, percent, currency
7982 skipHeader : boolean ;
8083 } [ ] ;
@@ -234,26 +237,23 @@ export function execGenExcelFuncs(sheetsData: SheetData[], excelConfigs: ExcelCo
234237 } ) || [ ] ;
235238
236239 // Add rows with data types
237- rows . forEach ( ( row ) => {
238- row . forEach ( ( value , colIdx ) => {
239- const cellType = columnTypes [ colIdx ] ;
240+ rows . forEach ( ( rowData ) => {
241+ rowData . forEach ( ( cellData , colIdx ) => {
242+ const { type = 'static_value' , value } = cellData ;
243+ const valueType = columnTypes [ colIdx ] ;
240244 const format = columnFormats [ colIdx ] ;
241245 let cellValue : any = value != null ? value : '' ; // Handle empty/null values
242246 const cell = worksheet . getCell ( rowIndex , startCol + colIdx ) ;
243247 // Check if the value is a formula
244- if ( typeof cellValue === 'object' ) {
245- if ( cellValue . formula && cellValue . formula !== '' ) {
246- const formulaCell : any = { formula : cellValue . formula } ; // Handle formula
247- if ( cellType === 'percent' || cellType === 'currency' || cellType === 'number' || cellType === 'date' ) {
248- cell . numFmt = format ; // Apply number format
249- }
250- cell . value = formulaCell ;
251- } else {
252- cell . value = '' ;
248+ if ( type == 'formula' ) {
249+ const formulaCell : any = { formula : cellValue } ; // Handle formula
250+ if ( valueType === 'percent' || valueType === 'currency' || valueType === 'number' || valueType === 'date' ) {
251+ cell . numFmt = format ; // Apply number format
253252 }
253+ cell . value = formulaCell ;
254254 } else {
255255 // Assign cell type based on the header definition
256- switch ( cellType ) {
256+ switch ( valueType ) {
257257 case 'number' : {
258258 cellValue = ! isNaN ( Number ( cellValue ) ) ? Math . round ( Number ( cellValue ) ) : cellValue ;
259259 cell . value = cellValue ;
0 commit comments