Skip to content

Commit

Permalink
Merge pull request #146 from dakira/document-column-width
Browse files Browse the repository at this point in the history
Add some documentation to explain how to change column widths
  • Loading branch information
freekmurze committed May 25, 2023
2 parents 9e7f872 + c2b0fe8 commit 150ec15
Showing 1 changed file with 19 additions and 0 deletions.
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

0 comments on commit 150ec15

Please sign in to comment.