Hello,
I have two Worksheets in a Workbook.
When I remove Worksheets[0], save Workbook to file (Excel), and a exception will happen as "object reference not set to an instance of an object".
My code as below:
using (Workbook book = new Workbook())
{
book.LoadFromFile(@"D:\ClosedXMLDonutChart.xlsx");
Worksheet sheet = book.Worksheets[0];
Worksheet sheetChart = book.Worksheets.Add("Chart");
..................Add Chart in sheetChart .......................
book.Worksheets[0].Remove();
book.SaveToFile(@"D:\DonutChart.xlsx", ExcelVersion.Version2010);
}
Image in attachment.
Because I am from Taiwan, error showed in Chinese .
It translated to English is "object reference not set to an instance of an object".
Please help me!
Thanks!