RadSpreadStreamProcessing worksheetImporter.Rows only ever reads first row

1 Answer 147 Views
Let's talk about telerik (the good and the bad)
Cori
Top achievements
Rank 1
Cori asked on 10 May 2023, 08:32 PM
using (var memoryStream = new MemoryStream(bytes))
                {
                    using (var workBookImporter = SpreadImporter.CreateWorkbookImporter(SpreadDocumentFormat.Xlsx, memoryStream))
                    {
                        foreach (var worksheetImporter in workBookImporter.WorksheetImporters)
                        {
                            int rowCounter = 0;
                            foreach (var rowImporter in worksheetImporter.Rows)
                            {
                                if (rowCounter < skipHeaderRows)
                                {
                                    rowCounter++;
                                    continue;
                                }
                                var county = rowImporter.Cells.ElementAt(6).Value;
                                counties.Add(county);
                            }
                        }
                    }
                }
using (var memoryStream = new MemoryStream(bytes))
                {
                    using (var workBookImporter = SpreadImporter.CreateWorkbookImporter(SpreadDocumentFormat.Xlsx, memoryStream))
                    {
                        foreach (var worksheetImporter in workBookImporter.WorksheetImporters)
                        {
                            int rowCounter = 0;
                            foreach (var rowImporter in worksheetImporter.Rows)
                            {
                                if (rowCounter < skipHeaderRows)
                                {
                                    rowCounter++;
                                    continue;
                                }
                                var county = rowImporter.Cells.ElementAt(6).Value;
                                counties.Add(county);
                            }
                        }
                    }
                }

worksheetImporter.Rows only ever contains the first row of the spreadsheet. I tried downloading the same bytes to a file, and the other rows are there.  Is there an issue with the library?  I used this a couple weeks ago and it worked fine, but now it's broken.

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 11 May 2023, 06:24 AM

Hello Cori,

It seems that this is a known issue with the library. The issue is already logged on our feedback portal. You can track its progress, subscribe to status changes, and add your comment here: SpreadStreamProcessing: Iterating through the rows without reading the cells is not skipping the rows

As a workaround, I would suggest iterating through the cells of each row, whether you will use them or not. Just use an empty for-each like this:

foreach (var ci in ri.Cells)
{
}

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Cori
Top achievements
Rank 1
commented on 11 May 2023, 02:10 PM

Yes that worked, thank you!
Also FYI for anyone else, using rowImporter.RowIndex and cellImporter.ColumnIndex works better than using a manual counter like I had above, because the importers skip empty cells.
Tags
Let's talk about telerik (the good and the bad)
Asked by
Cori
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or