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 XLSX option helpers to SimpleExcelReader #178

Merged
merged 5 commits into from
Sep 23, 2024

Conversation

brodos
Copy link
Contributor

@brodos brodos commented Sep 20, 2024

This PR adds the XLSXOptions to SimpleExcelReader, which then allows using some new helpers to set some options for XLSX files.

Preserve date formatting

By default, when reading a spreadsheet with dates or times, the values are returned as DateTimeImmutable objects. To return a formatted date (e.g., “9/20/2024”) instead, use the preserveDateTimeFormatting method. The date format will match what’s specified in the spreadsheet.

$rows = SimpleExcelReader::create($pathToXlsx)
    ->preserveDateTimeFormatting()
    ->getRows();

Preserve empty rows

You can preserve empty rows by using the preserveEmptyRows method.

$rows = SimpleExcelReader::create($pathToXlsx)
    ->preserveEmptyRows()
    ->getRows();

@Nielsvanpach
Copy link
Member

Nice PR, thanks!

@Nielsvanpach Nielsvanpach merged commit d92e3b5 into spatie:main Sep 23, 2024
10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants