Updating existing excel blows up the size of the excel
akashkhan25 opened this issue Β· comments
Thanks a lot for the library! It's been very useful π
I've noticed that using the writer to update existing excel will increase the excel size by over 10X even if there's very small amount of changes made.
Steps to reproduce:
- Create an empty excel (Note the size. For me empty excel is ~ 49KB)
- Execute the following to add some columns to the excel and write it
let headers = vec!["column_a","column_b"];
let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap();
let worksheet = book.get_sheet_by_name_mut("Sheet 1").unwrap();
let col_count = worksheet.get_highest_column() + 1;
worksheet.insert_new_column_by_index(&col_count, &(headers.len() as u32));
for (i, header_val) in headers.iter().enumerate() {
let col_index = col_count + (i as u32);
let cell = worksheet.get_cell_by_column_and_row_mut(&col_index, 2);
cell.set_value(header_val);
}
umya_spreadsheet::writer::xlsx::write(&book, path)
- The size of the excel is now 630KB.
Note: Opening the file in Excel and saving without any changes will fix the file size back to expected size.
Originally I noticed it on adding even 1 column on an input of size 500KB blew up the file size to 5.6MB. Reading it back caused memory usage to spike