Hi,
I am facing the following issue.
I open existing excel with the help of Xamarin stream IO. Actually I want to update values in a cell which will change the other values in the another worksheet(in the same workbook) based on the formula in the original worksheet.
I am able to modify the value in the newly written sheet but the values in other worksheet (in the same workbook) are not updated as per the formula.
Example- Workbook1--Sheet1- A3=2. ---> Workbook1--Sheet2- A3= 4 [ something like Formula A3[sheet1]*2]
I am able to create new workbook2, update the value of A3 in sheet1 to '4'' but the formula is not applied in the sheet2 and retains the old value only.
Please help me resolve this.
Please find my code chunk below. Thanks in advance.
void OnButtonClicked(object sender, EventArgs args)
{
Debug.WriteLine(NumberEntry.Text);
//Create an instance of ExcelEngine.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2010;
string resourcePath = "SyncfusionExcelDemo.Employee.xlsx";
//"App" is the class of Portable project.
Assembly assembly = typeof(App).GetTypeInfo().Assembly;
Stream fileStream = assembly.GetManifestResourceStream(resourcePath);
//MemoryStream stream2 = new MemoryStream();
//stream2 = (MemoryStream)fileStream;
//Opens the workbook
IWorkbook workbook = application.Workbooks.Open(fileStream);
IWorksheet worksheet = workbook.Worksheets[0];
//update the cell with new value
worksheet["A3"].Text = "5";
//workbook.Worksheets[0]["A3"].Text = "4";
workbook.Worksheets[0].EnableSheetCalculations();
workbook.Worksheets[1].EnableSheetCalculations();
ICalculationOptions cal = workbook.CalculationOptions;
cal.RecalcOnSave = true;
workbook.CalculationOptions.IsIterationEnabled = true;
MemoryStream stream = new MemoryStream();
workbook.SaveAs(stream);
workbook.Close();
excelEngine.Dispose();
//Save the stream into xlsx file
Xamarin.Forms.DependencyService.Get<ISave>().SaveAndView("sample.xlsx", "application/msexcel", stream);
}
}