I using the OpenXML library to take a datatable and paste it into a pre formatted excel file. This works fine.
The problem I have is there is a subtotal row at the top of the pre-formatted excel file, that is set to subtotal each column of this data (so there is a subtotal at the top of each column). When I open the excel file after it has been created, these values are all set to 0, they have not updated when the datatable was inserted. If you highlight one of these subtotal cells and then press enter, it updates and shows the right value.
What is the easiest way to get these values to update and show the correct value as soon as the user opens the downloaded spreadsheet?
Code for creating the spreadsheet:
MemoryStream memoryStream = SpreadsheetReader.StreamFromFile(TemplateDirectory + @"\" + "exceltTemplate.xlsx");
doc = SpreadsheetDocument.Open(memoryStream, true);
worksheetPart = SpreadsheetReader.GetWorksheetPartByName(doc, currentSheetName);
writer = new WorksheetWriter(doc, worksheetPart);
cellName = "A8";
writer.PasteDataTable(reports.Tables[0], cellName);
SpreadsheetWriter.Save(doc);