RE: Aspose.Cells .Net Version - 7.4.0.3 ( and 7.4.2 )
Our problem occurs when we attempt to strip off the data from an existing worksheet using Cells.DeleteRow with any workbook that contains an additional worksheet with external data connections. I have attached an example .xlsm file which causes the error.
Here is a listing of the code being used:
Workbook workbook = new Workbook(filePath);
Worksheet wksheet = workbook.Worksheets["Details"];
if (wksheet.ListObjects.Count > 0)
{
ListObject data = wksheet.ListObjects[0];
wksheet.Cells.DeleteRows(4, 1);
}
This feature was working with an earlier version of Aspose - 6.0.1 - but with release of Aspose.Cells .Net version 7.4.0.2, the below error results. ( I also tried with the latest - 7.4.2 which produces the same error.)
Our purpose is to strip all of the data to save a smaller template of the workbook, but for our example, we are just attempting to delete the 4th row of the "Details" worksheet containing our data when the NullReferenceException occurs. You can reproduce this error by applying the code above and processing a copy of the attached workbook .xlsm file. If you delete the worksheet with the pivot table and access to the external data connection, named "SourceData", Cells.DeleteRow works fine.
Error: Object reference not set to an instance of an object.
StackTrace:
at ..InsertRows(Int32 , Int32 , Worksheet )
at ..InsertRows(Int32 , Int32 , Worksheet )
at Aspose.Cells.Cells.DeleteRows(Int32 rowIndex, Int32 totalRows)
at Aspose.Cells.Cells.DeleteRows(Int32 rowIndex, Int32 totalRows, Boolean updateReference)
at AET_Play.Form1.StripDataOff(Workbook workbook) in C:\data\sourcecode\Visual Studio 2010\Projects\AET_Play\AET_Play\Form1.cs:line 476
at AET_Play.Form1.StripDataOff(String filePath) in C:\data\sourcecode\Visual Studio 2010\Projects\AET_Play\AET_Play\Form1.cs:line 430
at AET_Play.Form1.btnStripData_Click(Object sender, EventArgs e) in C:\data\sourcecode\Visual Studio 2010\Projects\AET_Play\AET_Play\Form1.cs:line 553
Please advise on what is causing this error and how to address it with the latest Aspose.Cells for .Net.
Thanks much,
-Gary