c# - Document not saving when Created Using the Open XML Format SDK 2.0 CTP -
I want to create an excel document based on the template using Open XML Format SDK 2.0. I have followed this tutorial. My problem is that the rows and cells I put in the documents are not saved. When I open the document, it looks like a template.
No exception will be thrown when I run my code. I understand that the changes saved in the document should be emphasized, but how can I understand how.
Here are some of my codes:
Public Static Zero GenerateExcelReportToDisk () {Var Factory = New Factory (); Var generated = "result.xlsx"; Var newFile = Util.GetReportTargetPath () + Generated; Var templateFile = Util.GetReportTemplatePath () + @ "template.xlsx"; File. Copy (templatefile, newfile, true); (Var myWorkbook = SpreadsheetDocument.Open (newFile, true)) using {var workbookPart = myWorkbook.WorkbookPart; Var Worksheet = Workbook page. Worksheet pars first of all (); Var sheetdata = worksheetparty Worksheet Gatefest Chald & lt; SheetData & gt; (); // Get Data Data Data = Factory.GetAilFixers (). Take (20); Int rowIndex = 3; FORECA (difference in data) {var PCRAT = stability. PCRT; Var account = stability. Charger! = Null? Stability Charger. Short name: empty; Var area = stability. Rule! = Null? Stability Region Group name: zero; // CreateContentRow is exactly like the above tutorial Var row = CreateContetRow (line indland, region, PCRAT, account); RowIndex ++; SheetData.AppendChild (line); } // tried to add myWorkbook WorkbookPart.Workbook.Save (); Here, but it does nothing myWorkbook.Close (); OK, I was successful in explaining it myself a little later. Here in the case of answering it will help someone (including me): myWorkbook.Close () in the row above; Add worksheetPart.Worksheet.Save (); Simple as that ...
Comments
Post a Comment