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

how to iterate rows in Worksheet?

Open SET001 opened this issue 10 months ago • 3 comments

this might be something super obvious but somehow I still missing this part even after reading docs. So how do I iterate rows in Worksheet?

SET001 avatar Apr 06 '25 14:04 SET001

so far I only find this way to iterate rows:

(1..data.get_highest_row()).for_each(|i|{
  let row = data.get_collection_by_row_to_hashmap(&i);
  ...
});

but maybe it would be better to implement Iterator or IntoIterator for Worksheet?

SET001 avatar Apr 06 '25 14:04 SET001

@SET001 Thank you for contacting us. Currently, the following can be implemented.

for row_dimension in data.get_row_dimensions() {
    let row = data.get_collection_by_row_to_hashmap(row_dimension.get_row_num());
}

However, get_row_dimensions() has the following limitations The data is not sorted. Empty rows are not included.

MathNya avatar Apr 07 '25 08:04 MathNya

I believe future versions will have iter_cells_by_row type API which has already been merged in, I think.

schungx avatar Apr 08 '25 00:04 schungx