fix issue 578.#644
Conversation
It seems to me the best solution is to always return data to the user even if he asks for more than what exists in the Excel Row.
|
However, the solution that I implemented, when using this library, seems to me to make the library easy to use. using While, it seems to me not the best solution. I suggest the following approach This is how I use the library: using (ExcelReader excel = new ExcelReader(FileInfo.Path))
{
foreach (var Row in excel)
{
<...>
}
}For use, I just implemented the following code public IEnumerator<ExcelRow> GetEnumerator()
{
while (Read())
{
var CurrentRow = ReadRow();
yield return CurrentRow;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public object[] ReadRow(int width = 100)
{
int max = FieldCount > width ? width : FieldCount;
var row = new object[max];
for (int i = 0; i < max; i++)
{
row[i] = RowCells[i]?.Value;
}
return row;
}I think If you think this is a good idea, I could implement it. |
|
Thanks. The implementation should follow the contract as specified which I think you've already done. I'll take closer look after the holidays. I don't think the ReadRow helper adds enough value to add to the core library. |
|
Could you add tests for the other supported file formats as well? |
|
Yes, I can do it after my vacation. But I'm not sure that is useful, because I just add using of RowCells[I].Value. |
|
Good afternoon, I'm not sure if you saw the changes. But I have added tests for supported files. |
Based on issue 578
Add Inplementation of GetValues(object[] values)
It seems to me the best solution is to always return data to the user even if he asks for more than what exists in the Excel Row.