excelize icon indicating copy to clipboard operation
excelize copied to clipboard

StreamWriter-like API when reading

Open thomascharbonnel opened this issue 2 years ago • 2 comments

Discussed in https://github.com/qax-os/excelize/discussions/1276

Originally posted by thomascharbonnel July 11, 2022 Hello,

First, thanks a lot for the amount of work you have put into this library, it's great! I'm happy to finally have an alternative to Apache POI!

I have a question that is somewhat related to an issue that was open earlier. Currently, excelize has a "stream reader" API using f.Rows() and row.Columns. Now, what Columns() returns isn't identical to what is expected when writing to a worksheet using StreamWriter. By that i mean that Columns() will only give you the cells' values, not all its attributes (value, style, formula), while on the other hand, streamwriter allows you to write the value+style+formula. I'd like to create an API similar to StreamWriter when reading (ie. i'd like to be able to read the value+style+formula at the same time when reading a cell), do you think that would be a good idea? If yes, any pointers to get started?

Thank you! :pray:

thomascharbonnel avatar Jul 22 '22 07:07 thomascharbonnel

Hi @xuri,

This is a WIP for this feature: https://github.com/qax-os/excelize/compare/master...thomascharbonnel:excelize:1284-streamreader-return-cell(so some of the tests aren't passing yet)

I've reused StreamWriter's Cell structure, though it might make sense to create a separate structure? I was thinking, in order to keep the ability for users to get a string with the proper excel styling, to define the appropriate String() on Cell.

Please feel free to suggest improvements if you have any in mind! Thank you!

thomascharbonnel avatar Jul 25 '22 07:07 thomascharbonnel

Thanks for your issue. The stream function was created for reading and writing a large data efficiently, at that time, I think maybe getting the value of the cell is the most typical scenario, getting the other attributes of the cell was not very usually, user can get these attributes by normal mode functions, so I have not implemented this feature.

I reconsider this design at this time, and I've left some comments for the draft PR.

xuri avatar Jul 27 '22 16:07 xuri