@@ -20,6 +20,9 @@ using (ExcelEngine excelEngine = new ExcelEngine())
2020 //Loads an xls file
2121 FileStream fileStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
2222 IWorkbook workbook = application.Workbooks.Open(fileStream);
23+
24+ //Set the workbook version to xlsx
25+ workbook.Version = ExcelVersion.Xlsx;
2326
2427 //Saving the workbook as stream in xlsx format
2528 FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
@@ -37,6 +40,9 @@ using (ExcelEngine engine = new ExcelEngine())
3740 //Loads an xls file
3841 IWorkbook workbook = application.Workbooks.Open("InputTemplate.xls");
3942
43+ //Set the workbook version to xlsx
44+ workbook.Version = ExcelVersion.Xlsx;
45+
4046 //Saving the workbook in xlsx format
4147 workbook.SaveAs("Output.xlsx");
4248}
@@ -47,10 +53,13 @@ Using engine As ExcelEngine = New ExcelEngine()
4753 Dim application As IApplication = engine.Excel
4854 application.DefaultVersion = ExcelVersion.Xlsx
4955
50- ' Loads an xls file
56+ 'Loads an xls file
5157 Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xls")
5258
53- ' Saving the workbook in xlsx format
59+ 'Set the workbook version to xlsx
60+ workbook.Version = ExcelVersion.Xlsx;
61+
62+ 'Saving the workbook in xlsx format
5463 workbook.SaveAs("Output.xlsx")
5564End Using
5665{% endhighlight %}
0 commit comments