Skip to main content
Answer

How do I read all rows in an Excel file using XLSXReader?

  • September 5, 2025
  • 3 replies
  • 76 views

epetruncio
Jr Varsity II

I am trying to utilize the built in functionality PX.Data.XLSXReader to read an uploaded/imported Excel file. The problem I am having is that all rows above the row which is used to define the _headerRow within the file seem to be ignored and there is no way to reset the position on the reader above the row designated as the _headerRow that I can find.

In my Excel document, I have some header information I need to parse in rows above the _headerRow. Is there a way to parse these rows, or do I need to use a different Excel reader?

If I need to utilize a different Excel reader, are there any requirements or rules to using external open source NuGet packages I need to be aware of when choosing one for the Excel reader?

Best answer by epetruncio

I have decided that since I have access to the XLSXReader code, to copy the code, paste it in a local file to my project, rename it so it doesn’t conflict with the current XLSXReader, and modify it to how I’d like it to work.

3 replies

Forum|alt.badge.img+7
  • Captain II
  • September 6, 2025

epetruncio
Jr Varsity II
  • Author
  • Jr Varsity II
  • September 8, 2025

Thank you for the response Django.

This article was helpful in initially setting up the reader, but it does not help with the situation I am facing. I know that Sergey mentions on the bottom that one might need to skip header rows, but I am not facing this problem. With my Excel file, it is skipping the first 4 lines and starting with the grid instead of starting with the very first row and allowing me to fetch the header data. 

I believe the reason for this is how the inside object _headerRow is defined. Viewing the code, the object does call “MoveNext” until it meets the criteria to fill _headerRow. I figured the Reset() functionality would reset said index, but it seems to only reset the index to the same row _headerRow is defined on.

I’m still trying to find other solutions in the mean time, but would appreciate any other ideas to try!

 

UPDATE: I tried a few things and found that the “Reset()” function is what is setting the IndexKeyPairs as well as leaving the cursor at the row that was used to define _headerRow. If I don’t call Reset(), then when trying to call MoveNext(), it will just hit the end of the file right away and be considered complete. 

Is there a manual way to set the index to the first row of the Excel file for this object, or is Reset the only method?


epetruncio
Jr Varsity II
  • Author
  • Jr Varsity II
  • Answer
  • September 15, 2025

I have decided that since I have access to the XLSXReader code, to copy the code, paste it in a local file to my project, rename it so it doesn’t conflict with the current XLSXReader, and modify it to how I’d like it to work.