Reference/Formula not updated inside a textbox

As in the attached spreadsheet, when I reference a cell from within a textbox, the textbox does not get updated, even after calling CalculateFormula. Cells that reference other cells get refreshed, but the textbox does not. Please see my attached spreadsheet and code below.


using (Workbook workbook = new Workbook(“Book1.xlsx”))
{
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells[“A1”].Value = 55;
workbook.CalculateFormula();
workbook.Save(“Book1.tif”), SaveFormat.TIFF);
}

After saving this to an image, I see that cell A3 gets properly updated, but the textbox which references cell A3 does not.

Am I missing something?

Hi,

Thanks for your posting and using Aspose.Cells.

Please call Shapes.UpdateSelectedValue() method which will fix your issue.

Here is a sample code for your reference. Changes are highlighted in red color. Please try it at your end and let us know your feedback.

C#

Workbook workbook = new Workbook(“book1.xlsx”);
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells[“A1”].Value = 55;
workbook.CalculateFormula();
worksheet.Shapes.UpdateSelectedValue();
workbook.Save(“Book1.tif”, SaveFormat.TIFF);

That doesn’t seem to help at all for me. Is this an Excel limitation?

Hi,

Thanks for your posting and using Aspose.Cells.

It is not Microsoft Excel limitation, it is Aspose.Cells limitation. Aspose.Cells introduced Shapes.UpdateSelectedValue() method for performance reason. You can also call this method for individual shape like the following

//Call this method for first shape
worksheet.Shapes[0].UpdateSelectedValue();

I have also attached the output tiff image generated with the given code above for your reference. Please download and check it. Please also clarify what issues you are facing with this method so that we could look into it and help you. Thanks for your cooperation.

Sorry. I got this post mixed up with another one. This does fix this issue. Thanks.

Hi,

Thanks for your clarification and using Aspose.Cells.

It is good to know that the suggested method resolved your issue. Let us know if you encounter any other issue, we will be glad to look into it and help you further.