Bug in v.7.5.1.0: NullReferenceException in workbook.Worksheets.AddCopy(index)

Hi,

The exception happens when the sheet being copied contains Pivot Table (the solution and Excel file to replicate the bug are attached):


using (Stream stream = new MemoryStream(inputFileBytes,true)) {
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(stream);
int copyIndex = workbook.Worksheets.AddCopy(0); <---- EXCEPTION HERE!

}

Exception details:
{“Object reference not set to an instance of an object.”}

Stack Trace:
at . . ( )
at Aspose.Cells.Pivot.PivotFieldCollection. (PivotField , Int32 )
at Aspose.Cells.Pivot.PivotFieldCollection.Add(PivotField pivotField)
at Aspose.Cells.Pivot.PivotTable.AddFieldToArea(PivotFieldType fieldType, PivotField pivotField)
at Aspose.Cells.Pivot.PivotTable.AddFieldToArea(PivotFieldType fieldType, Int32 baseFieldIndex)
at . .Copy( )
at Aspose.Cells.Pivot.PivotTable.Copy(PivotTable )
at Aspose.Cells.Pivot.PivotTableCollection.Copy(PivotTableCollection )
at Aspose.Cells.Worksheet.Copy(Worksheet sourceSheet, CopyOptions copyOption)
at Aspose.Cells.Worksheet.Copy(Worksheet sourceSheet)
at Aspose.Cells.WorksheetCollection.AddCopy(Int32 sheetIndex)
at AsposeAddCopyTest.Program.Main(String[] args) in c:\Users\kirylkavalenka\Documents\Visual Studio 2012\Projects\AsposeAddCopyTest\AsposeAddCopyTest\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()



Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We were able to replicate this exception using the following code with your source file. We have logged this issue in our database. We will look into it and resolve this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-41866.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\AsposeAddCopyTest\AsposeAddCopyTest\Resources\AddCopyTest.xlsx”;


Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(filePath);

int copyIndex = workbook.Worksheets.AddCopy(0);

Thank you, Shakeel.

Could you please give me an indication of when the bug would be resolved? This issue is very important and urgent for our business.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We have checked your issue status from our database. Your issue is in progress. Please spare us some time. Once, there is some update for you, we will let you know asap.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We have fixed the issue.

Please download and try this fix: Aspose.Cells for .NET v7.5.1.3 and let us know your feedback.