MortalreminderPT / edit-xlsx

A quick and easy-to-use Rust library for Excel file editing.
https://crates.io/crates/edit-xlsx
22 stars 4 forks source link

Read cell content and foreground and background color #6

Closed mschnell1 closed 5 months ago

mschnell1 commented 6 months ago

Hi Experts, Sorry for abusing an issue for asking for help, but I don't find any documemntation or examples for the supposedly trivial issue.

I'd like to read the Data content, background and foreground colors of all cells in am XLSX sheet. (The goal is to do a XLS-> ADOC converter. I don't want to write an XLSX file)

I do find set_...() functions for many cell propertiesm, but no "get_...()" functionality to read an existing workbook.

Any help ? -Thanks

MortalreminderPT commented 6 months ago

Unfortunately, there is currently no method provided for reading sheet contents or format. I've listed these features in the development plan and will release them in version 0.4. By the way, if you want to follow their development progress, you can check the dev-0.4 commit history.

mschnell1 commented 6 months ago

Thanks for the fast answer ! This is astonishing: Write is possible, Read is not....

Moreover it's astonishing that there is no appropriate issue and Merge request. (I certainly would have found those...)

mschnell1 commented 5 months ago

I'll try to check out v0.4 and so some tests....

mschnell1 commented 5 months ago

Yeah ! I see very active development. Thanks ! With v0.4 I can read the cell content 👍
And Border Color 👍 👍
Hoping for Text and background colors ...

mschnell1 commented 5 months ago

After setting filland fg_colorand bg_colorin formats.rs and color.rs to general pub, I do get some seemingly sensible value for the foreground color (as RGB) . 👍 👍 👍

But not yet the background color (As Index: always = 64 in my example).

mschnell1 commented 5 months ago

BTW to decently create an ADOC file, I additionally need the width of the table and the width of each column .... Seemingly the colsvector does not yet get filled with data from the xlsx file and hence the column widths are unknown.

MortalreminderPT commented 5 months ago

After setting filland fg_colorand bg_colorin formats.rs and color.rs to general pub, I do get some seemingly sensible value for the foreground color (as RGB) . 👍 👍 👍

But not yet the background color (As Index: always = 64 in my example).

Do you mean bg_color when adjusting the background color? I will try to modify thus making it easier to use. btw, not all fields can be made effective by modifying their access modifiers as I have not tested this way, after the functionality is perfected, I will make it easier by adding methods for the user to call.

MortalreminderPT commented 5 months ago

BTW to decently create an ADOC file, I additionally need the width of the table and the width of each column .... Seemingly the colsvector does not yet get filled with data from the xlsx file and hence the column widths are unknown.

Yes, due to the specificity of the cols, I haven't provided the ability to read the width yet, and in fact, the ability to read the height is unstable, and I'm going to include refining those features in the development plan. To facilitate feedback on the progress of the development of this feature, can you open a new issue for this purpose?

MortalreminderPT commented 5 months ago

I added some temporary interfaces to modify the column formatting (only column widths and background colors have been tested so far) and updated examples. Additionally, there is no specification provided in openxml for modifying the global background as far as I know, when making background changes in Excel, it just adjusts the background of the columns in a large range (this range is 1~2^14) to the desired colors.

MortalreminderPT commented 5 months ago

I've released version 0.4.1, which provides the ability to read text and styles that you can find in examples/read_and_copy to see the usage. In the current version, using format.fill to directly read `cells, rows, columns foreground and background colors is allowed.

MortalreminderPT commented 5 months ago

I'll mark this issue as completed, if you have problems with it, please don't hesitate to open an issue!