Free Support Forum -

Incorrect chart when saving as PDF

I have 3 sheets in my template: Data, RolledUp, SalesByRegion. My program (testing Aspose.Cells) loads the template, erases all the sample data on the Data sheet, writes a bunch of test data into the Data sheet (same formats), and then saves that with a new name. It then saves the SalesByRegion sheet as a PDF.

The SalesByRegion sheet contains a single chart, produced by referencing calculations based on named ranges.

But the chart in the PDF contains the wrong data…it’s a chart of from the sample Data on the template, but not from the new data written to the Data sheet.

Sample is attached.

In short:

Data sheet
Initially, just some sample sales data. Program erases that data, and replaces it with new data.
Relevant columns:
Sales, Region, Person

There are dynamic named ranges for Sales, Region and Person in the following form:

Sales= =OFFSET(Data!$C$2, 0, 0,0+ COUNTA(Data!$C$2:Data!$C$1000000),1)
Similar for Regions
Similar for Persons

So, this creates a range named “Sales” starting a Data!C2, and extending for however many rows there are down the C2 column that actually have data.

On the RolledUp sheet, we have rolled up sales figures by Region like so:
North = {=SUM((Regions=“North”) * (Sales))}
East = similar for "East"
South = similar for "South"
West = similar for "West"

So this is an array formula that does array multiplication by selecting those rows from Regions that equals “North”, and multiplying them by the value from Sales for the same row (it either gets multiplied by 1 or 0).

This sheet builds a chart based only on the values from the RolledUp sheet.

The saved workbook is correct on all sheets.

Oh…never mind. Needed to call Workbook.evaluateFormula().

It wasn’t until I posted the question that I figured out the magic words to search for. :slight_smile:


It’s good to know your problem is sorted out. I think, you are mentioning Workbook.CalculateFormula() method. I don’t find any Workbook.evaluateFormula() method.