I’m having a problem with some formula not being recalculated depending on how Excel is launched.
Using the following code:
Workbook wb = new Workbook(“Book1.xlsx”);
Double d = 0;
for (Int32 i = 0; i < 10; i++)
wb.Worksheets[“Sheet1”].Cells[i, 0].PutValue(d += 0.5);
wb.CalculateFormula();
wb.Save(“Book1-Out.xlsx”);
ProcessStartInfo startInfo = new ProcessStartInfo(@“C:\Program Files\Microsoft Office\Office14\Excel.exe”);
startInfo.Arguments = “Book1-Out.xlsx”;
startInfo.UseShellExecute = true;
Process p = new Process();
p.StartInfo = startInfo;
p.Start();
The code opens the attached Book1.xlsx, changes some values, recalculates, saves and then opens the file in Excel. When opened the contents of column C in Sheet1 and column A in Sheet2 show ‘#VALUE!’.
If I resave the file using Excel the resaved copy will not recalculate on open/close and will only show correct values if I do a full recalculate using ctrl-alt-f9.
If however I change my program to remove the code that starts Excel leaving this:
Workbook wb = new Workbook(“Book1.xlsx”);
Double d = 0;
for (Int32 i = 0; i < 10; i++)
wb.Worksheets[“Sheet1”].Cells[i, 0].PutValue(d += 0.5);
wb.CalculateFormula();
wb.Save(“Book1-Out.xlsx”);
I can execute the application, then open Book1-Out.xlsx using Windows Explorer. In this case the file opens in Excel and recalculates properly.
Any idea why the sheet does not recalculate when executed from my C# application? This issue is occurring with Aspose.Cells v6.0.0.0.
Thanks