You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a slight issue in how the Cell class works.
It seems there's two ways to add cells to a row. 1) Worksheet.AddValue 2) Add via IEnumerable<Cell> cells (after casting to a list) property on Row.
First one is slow as noted, but a handy shortcut.
Second one is error prone as no checks are made. So you could make two identical cells and add them to the row. i.e.
Also if Cells were added in incorrect order there is no sorting to put it right.
Although this would be a breaking change, I think a better approach would be to make Cells a IReadOnlyDictionary<int, Cell> instead. (The current IEnumerable is read only but casting to a list make it not read only, which is how the internal code updates).
For updating cells, Row.SetCellValue(int/string column, object value) Row.SetCellValue(Cell cell)
This could set existing cell value, add cell if it doesn't exist, or remove existing if value is null.
As a dictionary (underlying dictionary being SortedDictionary), it is ordered by index and prevents duplicates.
Of course, this would also apply to the Row class and Rows IEnumerable on worksheet too.
As it's a breaking change it may not be worth doing, however as the version is going to version 2, this indicates there is breaking changes, so this might be a good time to change this behaviour.
The text was updated successfully, but these errors were encountered:
I have a slight issue in how the
Cell
class works.It seems there's two ways to add cells to a row. 1)
Worksheet.AddValue
2) Add viaIEnumerable<Cell> cells
(after casting to a list) property onRow
.First one is slow as noted, but a handy shortcut.
Second one is error prone as no checks are made. So you could make two identical cells and add them to the row. i.e.
Also if Cells were added in incorrect order there is no sorting to put it right.
Although this would be a breaking change, I think a better approach would be to make Cells a
IReadOnlyDictionary<int, Cell>
instead. (The current IEnumerable is read only but casting to a list make it not read only, which is how the internal code updates).For updating cells,
Row.SetCellValue(int/string column, object value)
Row.SetCellValue(Cell cell)
This could set existing cell value, add cell if it doesn't exist, or remove existing if value is null.
As a dictionary (underlying dictionary being SortedDictionary), it is ordered by index and prevents duplicates.
Of course, this would also apply to the Row class and Rows
IEnumerable
on worksheet too.As it's a breaking change it may not be worth doing, however as the version is going to version 2, this indicates there is breaking changes, so this might be a good time to change this behaviour.
The text was updated successfully, but these errors were encountered: