Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:CreateColumn Index Index was out of range #1384 #1409

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions ooxml/XSSF/UserModel/XSSFTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ public XSSFTableColumn CreateColumn(String columnName, int columnIndex)
// Bug #62740, the logic was just re-using the existing max ID, not incrementing beyond it.
nextColumnId++;

// Add the new Column
// Add the new count
CT_TableColumn column = columns.InsertNewTableColumn(columnIndex);
columns.count = columns.count;
columns.count = (uint)columns.tableColumn.Count;

column.id = (uint)nextColumnId;
if (columnName != null)
Expand Down Expand Up @@ -665,20 +665,17 @@ public int FindColumnIndex(String columnHeader)
/// <returns></returns>
public List<XSSFTableColumn> GetColumns()
{
if (tableColumns == null)
var columns = new List<XSSFTableColumn>();
CT_TableColumns ctTableColumns = ctTable.tableColumns;
if(ctTableColumns != null)
{
var columns = new List<XSSFTableColumn>();
CT_TableColumns ctTableColumns = ctTable.tableColumns;
if (ctTableColumns != null)
foreach(CT_TableColumn column in ctTableColumns.GetTableColumnList())
{
foreach (CT_TableColumn column in ctTableColumns.GetTableColumnList())
{
XSSFTableColumn tableColumn = new XSSFTableColumn(this, column);
columns.Add(tableColumn);
}
XSSFTableColumn tableColumn = new XSSFTableColumn(this, column);
columns.Add(tableColumn);
}
tableColumns = columns;
}
tableColumns = columns;
return tableColumns;
}
public void RemoveColumn(XSSFTableColumn column)
Expand Down
Loading