PHP_XLSXWriter icon indicating copy to clipboard operation
PHP_XLSXWriter copied to clipboard

Set cell width only for some cells

Open bt-nn opened this issue 1 year ago • 2 comments

I found $writer->writeSheetHeader('Sheet1', $header, $col_options = ['widths'=>[10,20,30,40]] ); which worked as expected but when i try $writer->writeSheetHeader('Sheet1', $header, $col_options = ['widths'=>[null,null,null,40]] ); only the last col is displayed. Adding a if would be a fix for that

	protected function initializeSheet(...) {
		...
		if (!empty($col_widths)) {
			foreach($col_widths as $column_width) {
				if($column_width) { // <-- NEW LINE
					$sheet->file_writer->write('<col collapsed="false" hidden="false" max="'.($i + 1).'" min="'.($i + 1).'" style="0" customWidth="true" width="'.floatval($column_width).'"/>');
				} // <-- NEW LINE
                		$i++;
			}
		}

bt-nn avatar Jan 10 '24 16:01 bt-nn

您好,我已经收到您的信件,将尽快回复您。

sayid avatar Jan 10 '24 16:01 sayid

@bt-nn I've ported your changes to https://github.com/maksimovic/PHP_XLSXWriter/releases/tag/1.0.3

maksimovic avatar Jan 23 '24 09:01 maksimovic