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

XSSFTable.CreateColumn return System.ArgumentOutOfRangeException: Index was out of range #1384

Open
matteo-fantin opened this issue Jul 8, 2024 · 1 comment

Comments

@matteo-fantin
Copy link

2.7.0

Issue Description

When I try to create a new column on table, the method CreateColumn return the following error:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at NPOI.XSSF.UserModel.XSSFTable.CreateColumn(String columnName, Int32 columnIndex)

Codes

private static void CreateCustomSheet(IWorkbook workbook, List<MyCustomClass> values)
{
    // Create Sheet
    XSSFSheet sheet = (XSSFSheet)workbook.CreateSheet("SheetName");
    sheet.TabColor = new XSSFColor(SixLabors.ImageSharp.Color.Orange);

    // Create table
    XSSFTable table = sheet.CreateTable();
    table.Name = "TableName";
    table.CreateColumn("ColumnName1", 0); // <-- Here
    table.CreateColumn("ColumnName2", 1);
    table.CreateColumn("ColumnName3", 2);
    table.StyleName = XSSFBuiltinTableStyleEnum.TableStyleLight9.ToString();

    // Fill in the data
    // [...]
}
@wuzxc1230123
Copy link
Contributor

fix

@tonyqus tonyqus changed the title CreateColumn return System.ArgumentOutOfRangeException: Index was out of range XSSFTable.CreateColumn return System.ArgumentOutOfRangeException: Index was out of range Aug 28, 2024
@tonyqus tonyqus added this to the NPOI 2.8.0 milestone Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants