pola-rs / r-polars

Polars R binding
https://pola-rs.github.io/r-polars/
Other
473 stars 35 forks source link

Implement native method to export polars DataFrames to Excel #257

Closed ddotta closed 1 year ago

ddotta commented 1 year ago

In the cookbook I wrote this:

Unlike Python, the Polars R API does not yet contain native methods for exporting to Excel format. The best current solution is to use the data.frame conversion method and then use the {openxlsx} package or one of its {tablexlsx} wrapper to export these DataFrames in xlsx format.
Fortunately, the contributors to the R {polars} package are in full development and we hope soon to have methods for exporting to arrow or tibbles, for example! 💪

sorhawell commented 1 year ago

I took a look at py-polars impl it seems rely on python package XlsxWriter and not some dedicated polars/rust writer.

@ddotta what do you see as the benefits of writing directly to xlsx and not via data.frame? I guess xlsx-writers are rather slow so the data.frame will no be terrible.

ddotta commented 1 year ago

Yes, that's what I've seen too (the XlsxWriter dependency). I agree with you that it can't be much more efficient than converting to a data.frame and then using {openxlsx}. The only thing compared to a native method is that there's an extra conversion step...

I'll change the export text to include this. I think you can close the issue 👍 Thanks!

eitsupi commented 1 year ago

FYI, there is also openxlsx2 https://github.com/JanMarvin/openxlsx2

ddotta commented 1 year ago

Thanks @eitsupi I'll keep a note of it

eitsupi commented 1 year ago

Ok, I am closing this because the existing solutions seem sufficient.