ExcelProvider
ExcelProvider copied to clipboard
No detection of column changes between compile-time and runtime
User Story
As a user, I want to compile a project against one excel file at compile time and then run it against another excel file at runtime. The second excel file potentially has a different ordering or number of columns.
Description
After compiling a project against one Excel file, when I run the project against a second file, the direct reference of a property by name pulls data from a column by index, while the .GetValue("Property") pulls data from the correctly named column. At runtime, the direct property reference should point towards the referenced column, rather than the column index of itself in the original workbook.
Repro steps
- Create a program that prints
row.Column A
,row.Column B
androw.Column D
with the following excel file columns:
Column A | Column B | Column D |
---|---|---|
A Value | B Value | D Value |
- At runtime, point the following excel sheet at the program instead:
Column A | Column B | Column C | Column D |
---|---|---|---|
A Value | B Value | C Value | D Value |
- The values printed will be "A Value", "B Value" and "C Value", even though the original project references column D, rather than column C - it seems to reference the original columns by position rather than by name
- (Note: if you ran the original program with
row.GetValue("Column D")
, rather thanrow.Column D
, it would return "D Value"
Expected behavior
For the example above, it would be expected that the program prints out "A Value", "B Value" and "D Value", as we're still referencing the Column D from the original program
Actual behavior
For the example above, it actually prints out "A Value", "B Value" and "C Value"
Known workarounds
The known workaround is to use the .GetValue method instead of referencing the column directly, but then it defeats the purpose of the intellisense against each of the columns
Related information
- Windows
- .NET 8.0
- (Stable I believe)