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

Add some documentation to explain how to change column widths #146

Merged
merged 1 commit into from
May 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,25 @@ $writer->setHeaderStyle($style);

For more information on styles head over to [the Spout docs](https://github.com/openspout/openspout/tree/4.x/docs).

#### Setting column widths and row heights

By accessing the underlying OpenSpout Writer you can set default column widths and row heights and change the width of specific columns.

```php
SimpleExcelWriter::create(
file: 'document.xlsx',
configureWriter: function ($writer) {
$options = $writer->getOptions;
$options->DEFAULT_COLUMN_WIDTH=25; // set default width
$options->DEFAULT_ROW_HEIGHT=15; // set default height
// set columns 1, 3 and 8 to width 40
$options->setColumnWidth(40, 1, 3, 8);
// set columns 9 through 12 to width 10
$options->setColumnWidthForRange(10, 9, 12);
}
)
```

#### Creating an additional sheets

By default, the writer will write to the first sheet. If you want to write to an additional sheet, you can use the `addNewSheetAndMakeItCurrent` method.
Expand Down