Free Support Forum - aspose.com

InsertColumn doesn't work

When I try to use the Method InsertColumn(), I get a runtime error "NullReferenceException". My version is 4.0.1.0 and i'm using C#.

Example Code:

Workbook workbook = new Workbook();
//Open a designer file
string designerFile = MapPath("Designer") + \\DispoList.xls;
workbook.Open(designerFile);
// blank worksheet (template for new worksheets)
Worksheet blankWorksheet = workbook.Worksheets[0];
// delete unneccessary worksheets
workbook.Worksheets.Clear();

int newIndex = workbook.Worksheets.Add(SheetType.Worksheet);
workbook.Worksheets[newIndex ].Copy(blankWS);
Cells cells = workbook.Worksheets[newIndex ].Cells;

cells.InsertColumn(6); <- at this point the runtime error occurs

I read the documentation of inserting rows and columns very carfully, so i think its not my mistake.

Please try this attached version.

If it still doesn't work for you, please post your designer file here. I will check it ASAP.

Thank you for your fast response, but it still doesnt work - same error.

My DesignerFile is attached.

I found and fixed this bug. Please try this attached fix.