Hi Team,
This is my sample code to refresh my workbook and also refresh formulas. But this is not refreshing my formula when i download my data into excel except i copy and past the same data. Attached is the sample template. it is empty but if you copy and paste the same data, it will refresh the formula and plot my data.
protected void btnDownload_Click(object sender, EventArgs e)
{
Workbook wrk = new Workbook(Server.MapPath("Template/Technical_plot_TemplateV4.xlsx"));
Worksheet wrksht = wrk.Worksheets["Technical Limit Data"];
if ((DataTable)Session["dtModules2"] != null)
{
DataTable dt = (DataTable)Session["dtModules2"];
wrksht.Cells.ImportDataTable(dt, true, "A1");
XlsSaveOptions cell = new XlsSaveOptions();
Range range1 = wrksht.Cells.CreateRange("A1", "E" + wrksht.Cells.EndCellInColumn(0).Name);
int cellidx = wrksht.Cells.EndCellInColumn(0).Row;
int fcellidx = cellidx + 10 + 1;
Range range2 = wrksht.Cells.CreateRange("A1", "E" + fcellidx.ToString());
range2.Copy(range1);
wrk.CalculateFormula();
wrksht.Workbook.Settings.ReCalculateOnOpen = true;
wrksht.Workbook.Settings.CalcMode = Aspose.Cells.CalcModeType.Automatic;
wrk.Save(this.Response, "TechnicalLimitData.xlsm", ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Xlsm));
}
I will be glad if you guys can assit me.