Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set cell width only for some cells #354

Open
bt-nn opened this issue Jan 10, 2024 · 2 comments
Open

Set cell width only for some cells #354

bt-nn opened this issue Jan 10, 2024 · 2 comments

Comments

@bt-nn
Copy link

bt-nn commented Jan 10, 2024

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++;
			}
		}
@sayid
Copy link

sayid commented Jan 10, 2024 via email

@maksimovic
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants