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