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

ExcelOpenSpoutExporter: add support for non-string values #359

Merged
merged 1 commit into from
Oct 27, 2024

Conversation

mhvis
Copy link
Contributor

@mhvis mhvis commented Oct 24, 2024

We encountered an issue where we had a render callable which returned an int. That broke the exporter because I assumed that the value is always a string.

I had the idea (when looking at e.g. NumberColumn) that a callable given to render should always return a string. But that's not very clear in the documentation. But I also changed our render function to return a string.

We encountered an issue where we had a `render` callable which returned
an int. That broke the exporter because I assumed that the value is
always a string.

I had the idea (when looking at e.g. NumberColumn) that a callable given
to `render` should always return a string. But that's not very clear in
the documentation. But I also changed our `render` function to return a
string.
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.69%. Comparing base (0665897) to head (0ac88b3).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #359   +/-   ##
=======================================
  Coverage   94.69%   94.69%           
=======================================
  Files          37       37           
  Lines         999      999           
=======================================
  Hits          946      946           
  Misses         53       53           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@curry684
Copy link
Member

render returns mixed as per original design any 'stringable' is fine. I think the current PR is breaking/limiting in the current form as it will ignore integers and the like while they can be easily converted. We should just convert to string here as needed.

@mhvis
Copy link
Contributor Author

mhvis commented Oct 25, 2024

Okay that clears things up and makes sense, thanks!

This PR will not ignore an integer if it encounters one. It will pass the value directly to OpenSpout using Cell::fromValue(). OpenSpout will then write the value as a Number type in XSLX.
Other types which are also supported by that function will also work and have the correct type in XLSX.

If a value is passed that has a type which is not supported by the function above, there will likely be a TypeError. I could change this behaviour to instead try to convert the value to a string, and if that doesn't work, just silently ignore the value

In case of strings, they will be truncated and stripped of HTML. Other types will not be modified and passed to OpenSpout as-is.

@mhvis mhvis changed the title ExcelOpenSpoutExporter: add check for non-string values ExcelOpenSpoutExporter: add support for non-string values Oct 25, 2024
@curry684
Copy link
Member

Oops, Github diff view hid that you're still inserting it in line 62 indeed. Then it's fine like this indeed.

@curry684 curry684 merged commit 5cc4e9d into omines:master Oct 27, 2024
5 of 11 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