MortalreminderPT / edit-xlsx

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

RichText can only be constructed, but not read #20

Closed FlixCoder closed 5 months ago

FlixCoder commented 5 months ago

When reading cells with rich text formatting, one can not retrieve the value as it seems. Maybe I am missing something?

MortalreminderPT commented 5 months ago

This is because rich text is stored differently from normal text, the content of rich text is not stored in value. Therefore it is (temporarily) unreadable

MortalreminderPT commented 5 months ago

Can you read rich text content using the following method? I did a simple test and it worked in my test

let workbook = Workbook::from_path("tests/xlsx/rich-text.xlsx")?;
let worksheet = workbook.get_worksheet(1)?;
let cell = worksheet.read_cell("A1")?;
let rt = cell.rich_text.unwrap();
println!("{:?}", rt);
FlixCoder commented 5 months ago

Yes I tested that previously and it works. But there is only the Debug impl, no method to retrieve the values and formats ^^

mschnell1 commented 5 months ago

BTW I can "pretty print" Rich text by

          if let Some(rt) = cell_content.rich_text {
            let s = format!("{:?}", rt))
...

But the RichTexttype (result of cell_content.rich_text() ) is not available, because the words element in edit-xlsx-0.4.4/src/api/cell/rich_text.rs is not public or featuring a get function.

With my project I do need the "words"...

mschnell1 commented 5 months ago

@MortalreminderPT any news ?

MortalreminderPT commented 5 months ago

@MortalreminderPT any news ?

Yes, I see the problem. I'll fix it later.

MortalreminderPT commented 5 months ago

You can try reading rich text and its words with the new test case

mschnell1 commented 5 months ago

Thanks, with 0.4.5 it works