We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error in calculating cell exception after upgrade

I am getting the following exception from Aspose.Cells after Aspose upgrade.

Aspose.Cells.CellsException: Object reference not set to an instance of an object.
Error in calculating cell B5 in Worksheet Overview
Code: Formula
HResult: -2146232832
at Aspose.Cells.Workbook.CalculateFormula(Boolean ignoreError, ICustomFunction customFunction)
at Aspose.Cells.WorkbookDesigner.Process(Boolean isPreserved)

formula in the cell is =SUMPRODUCT((YEAR(RawData!A2:A90000) =2012) * (RawData!C2:C90000))

Hi,

Please download and try our latest fix/version: Aspose.Cells for .NET (Latest Version) if it works fine.

If you still find the issue, kindly attach your template file and sample code (runnable) to reproduce the issue on our end, we will check your issue soon.

Thank you.

Aspose version is 7.4.2.0

Template is attached.
Code to reproduce is very simple;

var license = new License();
using (var ms = new MemoryStream(asposeFiles.AsposeLicense.Aspose_Cells))
{
license.SetLicense(ms);
}
var template = new WorkbookDesigner();
template.Load(ReportTemplates.PearsonWeeklyReportTemplate);
template.Process();

Hi,

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

When we tried to run your code. Visual Studio complained no Load function is out there. Could you please check it at your end. Load method does not exist. We used the latest version of Aspose.Cells assembly.

Hi,


Well, also, with latest versions of the product, your code should be like following:

var template = new WorkbookDesigner();
template.Workbook = new Workbook(_______);
template.Process();

The reason for error may lie in your last line of code i.e.
template.Process();
You are calling this method without specifying DataSource for the under lying smart markers (that you have used in your template file), so you might get the error that you have mentioned in your first post. Please see the following sample code for correct procedure or ordering of the lines of code. e.g

/Create a workbook from Smart Markers template file
Workbook workbook = new Workbook(filePath);

//Instantiate a new WorkbookDesigner
WorkbookDesigner designer = new WorkbookDesigner();

//Specify the Workbook
designer.Workbook = workbook;

//Set the Data Source
designer.SetDataSource(dt_Sample);

//Process the smart markers
designer.Process();

//Save the Excel file
workbook.Save(filePath + “_out1.xlsx”, SaveFormat.Xlsx);

Also, please check the document for your complete reference on Smart Markers on how to use them with template files:
http://www.aspose.com/docs/display/cellsnet/Smart+Markers

If you still find the issue, kindly do provide a sample console application (runnable), zip it and post it with all the files (input file and output file etc.). We will check your issue soon.

Thank you.

I provided you minimum code to reproduce the problem. You are absolutely right template.Process(); throws exception. Moreover the issue was introduced in recent releases, year old aspose library was working fine. BTW template.Workbook.CalculateFormula(); will throw the same exception as well.


If you insist the full example is attached.

I am looking forward to issue resolution.

Hi,

Thanks for your posting and using Aspose.Cells.

After investigation, we were able to replicate the issue. We are getting the same exception in workbook.calculateFormula.

We
have logged this issue in our database. We will look into it and fix
it. Once the issue is fixed or we have some other update for you, we
will let you know asap.

This issue has been logged as CELLSNET-41583

C#

string filePath = @“F:\Shak-Data-RW\Downloads\PearsonWeeklyReportTemplate(1).xlsx”;
Workbook workbook = new Workbook(filePath);
workbook.CalculateFormula();
Console.WriteLine(workbook.Worksheets[“Calculation1”].Cells[“B5”].StringValue);

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 (Latest Version) and let us know your feedback.