|
| 1 | +--- |
| 2 | +title: How to convert xls document to xlsx format document |Syncfusion. |
| 3 | +description: This page explains how to convert xls document to xlsx format document using Syncfusion .NET Excel library (XlsIO). |
| 4 | +platform: file-formats |
| 5 | +control: XlsIO |
| 6 | +documentation: UG |
| 7 | +--- |
| 8 | + |
| 9 | +# How to convert xls document to xlsx format document? |
| 10 | + |
| 11 | +The following code illustrates how to convert xls document to xlsx format document. |
| 12 | + |
| 13 | +{% tabs %} |
| 14 | +{% highlight c# tabtitle="C# [Cross-platform]" %} |
| 15 | +using (ExcelEngine excelEngine = new ExcelEngine()) |
| 16 | +{ |
| 17 | + IApplication application = excelEngine.Excel; |
| 18 | + application.DefaultVersion = ExcelVersion.Xlsx; |
| 19 | + |
| 20 | + //Loads an xls file |
| 21 | + FileStream fileStream = new FileStream("InputTemplate.xls", FileMode.Open, FileAccess.Read); |
| 22 | + IWorkbook workbook = application.Workbooks.Open(fileStream); |
| 23 | + |
| 24 | + //Set the workbook version to xlsx |
| 25 | + workbook.Version = ExcelVersion.Xlsx; |
| 26 | + |
| 27 | + //Saving the workbook as stream in xlsx format |
| 28 | + FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); |
| 29 | + workbook.SaveAs(stream); |
| 30 | + stream.Dispose(); |
| 31 | +} |
| 32 | +{% endhighlight %} |
| 33 | + |
| 34 | +{% highlight c# tabtitle="C# [Windows-specific]" %} |
| 35 | +using (ExcelEngine engine = new ExcelEngine()) |
| 36 | +{ |
| 37 | + IApplication application = engine.Excel; |
| 38 | + application.DefaultVersion = ExcelVersion.Xlsx; |
| 39 | + |
| 40 | + //Loads an xls file |
| 41 | + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xls"); |
| 42 | + |
| 43 | + //Set the workbook version to xlsx |
| 44 | + workbook.Version = ExcelVersion.Xlsx; |
| 45 | + |
| 46 | + //Saving the workbook in xlsx format |
| 47 | + workbook.SaveAs("Output.xlsx"); |
| 48 | +} |
| 49 | +{% endhighlight %} |
| 50 | + |
| 51 | +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} |
| 52 | +Using engine As ExcelEngine = New ExcelEngine() |
| 53 | + Dim application As IApplication = engine.Excel |
| 54 | + application.DefaultVersion = ExcelVersion.Xlsx |
| 55 | + |
| 56 | + 'Loads an xls file |
| 57 | + Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xls") |
| 58 | + |
| 59 | + 'Set the workbook version to xlsx |
| 60 | + workbook.Version = ExcelVersion.Xlsx; |
| 61 | + |
| 62 | + 'Saving the workbook in xlsx format |
| 63 | + workbook.SaveAs("Output.xlsx") |
| 64 | +End Using |
| 65 | +{% endhighlight %} |
| 66 | +{% endtabs %} |
0 commit comments