@@ -45,7 +45,17 @@ const dateToNumber = (v, date1904) => {
4545 return ( epoch - Number ( new Date ( Date . UTC ( 1899 , 11 , 30 ) ) ) ) / ( 24 * 60 * 60 * 1000 ) ;
4646} ;
4747exports . dateToNumber = dateToNumber ;
48- const excelSheetFromDataSet = ( dataSet , bigHeading ) => {
48+ /**
49+ * This returns the worksheet object for the given dataSet, also accept bigHeading.
50+ *
51+ * @param dataSet - The ExcelSheetData array is required
52+ * @param bigHeading - ExcelSheetCol (Optional)
53+ * @returns WorkSheet Object
54+ *
55+ * @author Susanta Chakraborty
56+ * @date 2023-06-14
57+ */
58+ const excelSheetFromDataSet = ( dataSet , bigHeading , autoFilterForAllColumn ) => {
4959 /*
5060 Assuming the structure of dataset
5161 {
@@ -82,6 +92,12 @@ const excelSheetFromDataSet = (dataSet, bigHeading) => {
8292 rowCount += 1 ;
8393 }
8494 let columnsInfo = [ ] ;
95+ // if xStep has value then we need to skip some columns
96+ if ( xSteps > 0 ) {
97+ for ( let i = 0 ; i < xSteps ; i ++ ) {
98+ columnsInfo . push ( { wpx : 100 } ) ;
99+ }
100+ }
85101 if ( columns . length >= 0 ) {
86102 columns . forEach ( ( col , index ) => {
87103 let cellRef = xlsx_js_style_1 . utils . encode_cell ( { c : xSteps + index , r : rowCount } ) ;
@@ -93,6 +109,12 @@ const excelSheetFromDataSet = (dataSet, bigHeading) => {
93109 }
94110 getHeaderCell ( colTitle , cellRef , ws ) ;
95111 } ) ;
112+ if ( autoFilterForAllColumn ) {
113+ const filterRange = { s : { c : xSteps , r : rowCount } , e : { c : xSteps + dataSetItem . columns . length - 1 , r : rowCount } } ;
114+ const filterRef = xlsx_js_style_1 . utils . encode_range ( filterRange ) ;
115+ console . log ( filterRef ) ;
116+ ws [ '!autofilter' ] = { ref : filterRef } ;
117+ }
96118 rowCount += 1 ;
97119 }
98120 if ( columnsInfo . length > 0 ) {
0 commit comments