Skip to content

Commit

Permalink
fix:CreateColumn Index Index was out of range nissl-lab#1384
Browse files Browse the repository at this point in the history
  • Loading branch information
wuzxc1230123 committed Aug 27, 2024
1 parent 584c9a7 commit 0872d5f
Showing 1 changed file with 9 additions and 12 deletions.
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

0 comments on commit 0872d5f

Please sign in to comment.