MathNya / umya-spreadsheet

A pure rust library for reading and writing spreadsheet files
MIT License
239 stars 41 forks source link

Can I read the background color of the cell? #141

Closed 107295472 closed 7 months ago

MathNya commented 7 months ago

@107295472 I was surprised to see this question. Sorry, I did not implement a function to easily get backgroud color. We will improve it in the next version.

In the current version, it can be obtained as follows

const BG_COLOR: &str = "#333";
style.set_background_color(BG_COLOR);
sheet.set_style_by_range("A3:A4", style);

let bgcolor = sheet.get_style("A3").get_fill().as_ref().unwrap().get_pattern_fill().as_ref().unwrap().get_foreground_color().as_ref().unwrap().get_argb();
dbg!(bgcolor);
107295472 commented 7 months ago

Thanks