mk-j / PHP_XLSXWriter

Lightweight XLSX Excel Spreadsheet Writer in PHP
MIT License
1.84k stars 663 forks source link

How to hide specific columns? #313

Open prabakaran-p opened 2 years ago

prabakaran-p commented 2 years ago

Hi There,

I want to hide specific column in xlsx. I tried this way 'hidden'=>[1,1,1,1,0,0,0,0] in the writeSheetHeader and writeSheetRow. But it is hiding the entire row in the xlsx. `<?php set_include_path( get_include_path().PATH_SEPARATOR.".."); include_once("xlsxwriter.class.php");

$header = array( 'c1-text'=>'string',//text 'c2-text'=>'@',//text 'c3-integer'=>'integer', 'c4-integer'=>'0', 'c5-price'=>'price', 'c6-price'=>'#,##0.00',//custom 'c7-date'=>'date', 'c8-date'=>'YYYY-MM-DD', ); $rows = array( array('x101',102,103,104,105,106,'2018-01-07','2018-01-08'), array('x201',202,203,204,205,206,'2018-02-07','2018-02-08'), array('Total',302,303,304,305,306,'2018-03-07','2018-03-08') ); $writer = new XLSXWriter();

$writer->writeSheetHeader('Sheet1', $header, $style = array('widths'=>[40,50,20,10,40,50,20,10],'hidden'=>[1,1,1,1,0,0,0,0])); $style = array('widths'=>40, 'hidden'=>[1,1,1,1,0,0,0,0]); foreach($rows as $row){ $writer->writeSheetRow('Sheet1', $row, $style); } $writer->writeToFile(rand(1000,9999).'xlsx-simples.xlsx');

` Can anyone help me to find a solution?