jmcnamara / rust_xlsxwriter

A Rust library for creating Excel XLSX files.
https://crates.io/crates/rust_xlsxwriter
Apache License 2.0
250 stars 23 forks source link

Feature request: set a cell 's background color #82

Open tmacychen opened 5 months ago

tmacychen commented 5 months ago

Question

As the title says , when I want to set a cell's background color , which method should I can use ?

write_with_format must set a data for a cell , but the cell that I want to change it's background color already had a data .

  worksheet.write_with_format(4, 0, 3.00, &decimal_format)?;

when I use the method write_blank, I just got a blank cell without the data .

Please help me ,Thanks!

jmcnamara commented 5 months ago

when I want to set a cell's background color , which method should I can use ?

There isn't currently a way to do that. All of the current methods require that you set the data and format at the same time with one of the write_*_with_format() methods. However, it was/is planned to add methods that write the formatting separately from the data.

For the simple case of just adding cell data I can add that very soon. However, there is also the case where the user might want to merge the new format with the existing cell format. That will need a little bit more work/time.

If you are interested in the first/simpler use case I can add it and you can try it out.

tmacychen commented 5 months ago

when I want to set a cell's background color , which method should I can use ?

There isn't currently a way to do that. All of the current methods require that you set the data and format at the same time with one of the write_*_with_format() methods. However, it was/is planned to add methods that write the formatting separately from the data.

For the simple case of just adding cell data I can add that very soon. However, there is also the case where the user might want to merge the new format with the existing cell format. That will need a little bit more work/time.

If you are interested in the first/simpler use case I can add it and you can try it out.

That's great! I like to try it . In some case, I also need to read xlsx file and modify it. But in rust I seems have to use two different crates rather then in Python that use openpyxl lib. em..... what ever , it's a good crate to use , and faster!