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

`Spreadsheet::read_sheet_by_name` or `Worksheet::read`

Open KyGost opened this issue 3 years ago • 7 comments

When initialising lazily, one must initialise a sheet in order to interact with it. Currently that requires sheet index.

KyGost avatar Apr 09 '22 03:04 KyGost

use get_sheet_by_name_mut(sheetname)

cstkingkey avatar Apr 09 '22 04:04 cstkingkey

That's what I'm doing but I get a panic which says that I must read sheet first, before inserting rows.

KyGost avatar Apr 09 '22 04:04 KyGost

That's what I'm doing but I get a panic which says that I must read sheet first, before inserting rows.

I guess you were using non-mut version

cstkingkey avatar Apr 09 '22 05:04 cstkingkey

I guess you were using non-mut version

Nope

pub(crate) fn get_sheet_mut(&mut self, sheet_name: &str) -> Result<&mut Worksheet> {
  self.book
	.get_sheet_by_name_mut(sheet_name)
	.map_err(|_| SheetStorageError::FailedToGetSheet.into())
}

KyGost avatar Apr 09 '22 05:04 KyGost

I have checked the relevant sources and cannot find the cause. Can you tell us where the panic occurred?

MathNya avatar Apr 09 '22 15:04 MathNya

I'll see if I can make a better, more comprehensive example later, but for now, this:

reader::xlsx::read_lazy
get_sheet_by_name_mut
get_cell_by_column_and_row_mut
set_value
writer::xlsx::write

KyGost avatar Apr 10 '22 02:04 KyGost

Sorry it took so long to respond. I tried the above procedure with the latest version and did not encounter any errors. Please check again with the latest version.

MathNya avatar Jun 03 '22 14:06 MathNya