umya-spreadsheet icon indicating copy to clipboard operation
umya-spreadsheet copied to clipboard

Writing NaN results in a corrupted spreadsheet

Open Niatross opened this issue 9 months ago • 2 comments

Writing NaN using set_value will result in a corrupted spreadsheet

` let path = Path::new("test.xlsx"); let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap();

let sheet = book.get_sheet_mut(&0).unwrap();
sheet.get_cell_mut((1,7))
    .set_value("NaN");

umya_spreadsheet::writer::xlsx::write(&book, path).unwrap();`

This is because set_value tries to write this as a number (which feels like it should be supported) but ultimately results in a corruption warning when opening Excel.

I am currently not sure whether:

  • NaN in a numeric cell is not supported by Excel
  • NaN is supported but has been incorrectly implemented here

A temporary work around is to use set_value_string instead.

Permanent solutions:

  • Correctly implement NaN as a number cellvalue
  • set_value should correctly determine that the cell should be a string

Niatross avatar May 07 '25 08:05 Niatross

@Niatross Thank you for your report. We will address this in the next update.

MathNya avatar May 09 '25 07:05 MathNya

Fixed a bug. Please get the latest version.

MathNya avatar Jun 24 '25 05:06 MathNya