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

Free Support Forum - aspose.com

Refresh data

Sceneario:


1 - I open a spreadsheet that has two sheets. The first sheet references the second sheet.
2 - Then I update cells in the second sheet
3 - When I go to convert a spreadsheet to an image, the data in the first sheet does not update

How do I get the cell references to update before I do a sheet render?


private static void CreateJpegReport(Worksheet reportWorksheet, string pathToSaveFileAs)
{
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
imgOptions.OnePagePerSheet = true;
SheetRender sr = new SheetRender(reportWorksheet, imgOptions);
Bitmap bitmap = sr.ToImage(0);

// Removes trial info
bitmap = ImageUtil.RemoveTopAndBottom(bitmap, 20, 20);
// DONE removing trial info

bitmap = ImageUtil.CropWhitespace(bitmap);
bitmap.Save(pathToSaveFileAs);
}

Hi Matthew,

Thanks for your posting and using Aspose.Cells.

Please call Workbook.CalculateFormula() once you have updated the data in the second worksheet so that the data in first worksheet is refreshed.

It should fix your issue. Let us know if you still encounter any problem. We will look into it and help you asap.

That did it. You might mention that in your tutorials. It isn’t obvious when it should be called.


Thanks for resolving this so quickly.

Hi Matthew,


Its good to know that you are up and running again. Please feel free to write back in case you need our further assistance with Aspose.Cells APIs.

Moreover, we have noted down you suggestion to update our documentation (wherever applicable) to show that Workbook.Calculate method is necessary for correct rendering if base data source has been changed.