Put- Retrieve and Display Calculated cell value in webpage texbox

Hi Aspose Folks,
I’m trying to Put a value into a workbook cell, calculate a formula, then retrieve the calculated value from the workbook and post it into a textbox on a webpage (Using a webform c# in VS Express 2013). I’m struggling to get the right c# method of doing this from examples on your website.
In my example code below I’m trying to Put a value of 5 into cell A2. Get the workbook to calculate a formula in cell A1 (formula could be something like =5+A2). Retrieve the calculated value from cell A1 (5+5=10) then display the value in a textbox in the webpage. Can you help with the sample code below?
Many Thanks, Lee (PS-Sorry about the format of the text in this post)

   //Open template
    string path = MapPath("~");
    path = path.Substring(0, path.LastIndexOf("\\"));
    path += @"MyBook.xls";

    Workbook workbook = new Workbook(path); //Instantiate a new workbook
    Worksheet worksheet = workbook.Worksheets[0];

     Cell cellPut = worksheet.Cells["A2"];
     cellPut.PutValue(5); //PUT Value 5 into cell A2

     workbook.CalculateFormula; // CALCULATE ALL FORMULAS IN WORKBOOK

     Cell cellGet = worksheet.Cells["A1"];
     cellGet.Value; //GET CALCULATED VALUE FROM CELL A1

     textbox = cellGet; // DISPLAY THE VALUE OF cellGet in a textbox on the webpage

Hi,

Could you try to change the last lines of code:
i.e.,

…
cellGet.Value; //GET CALCULATED VALUE FROM CELL A1

textbox = cellGet; // DISPLAY THE VALUE OF cellGet in a textbox on the webpage

to:

string cellValue = cellGet.StringValue; //GET CALCULATED VALUE FROM CELL A1

TextBox1.Text = cellValue; // DISPLAY THE VALUE OF cellGet in a textbox on the webpage

if it works fine for your needs.

Thank you.

Hi Lee,


Thank you for contacting Aspose support.

I have used your code in a WebForm application to show the calculated value in a Textbox with out any issue. Please check the attached sample application in an archive. Please note, the archive also contains the assembly from the latest version of Aspose.Cells for .NET 8.5.0 & a sample spreadsheet, so all you need to do is to load the project in Visual Studio 2013 and execute it.

Ok many thanks. I’ll give it a go
Lee