Loading and saving workbook in WPF
Opening an existing workbook
You can open an existing workbook by using the overloads of Open methods of IWorkbooks interface.
//Creates a new instance for ExcelEngine
ExcelEngine excelEngine = new ExcelEngine();
//Initialize IApplication
IApplication application = excelEngine.Excel;
//Loads or open an existing workbook through Open method of IWorkbooks
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
'Creates a new instance for ExcelEngine
Using excelEngine As New ExcelEngine()
'Initialize IApplication
Dim application As IApplication = excelEngine.Excel
'Loads or open an existing workbook through Open method of IWorkbooks
Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")
End Using
Saving an Excel workbook
You can also save the created or manipulated workbook using overloads of SaveAs methods.
//Creates a new instance for ExcelEngine
ExcelEngine excelEngine = new ExcelEngine();
//Initialize IApplication
IApplication application = excelEngine.Excel;
//Loads or open an existing workbook through Open method of IWorkbooks
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
//To-Do some manipulation
//To-Do some manipulation
//Set the version of the workbook
workbook.Version = ExcelVersion.Xlsx;
//Save the workbook to disk in xlsx format
workbook.SaveAs("Output.xlsx");
'Creates a new instance for ExcelEngine
Using excelEngine As New ExcelEngine()
'Initialize IApplication
Dim application As IApplication = excelEngine.Excel
'Loads or open an existing workbook through Open method of IWorkbooks
Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx")
'To-Do some manipulation
'To-Do some manipulation
'Set the version of the workbook
workbook.Version = ExcelVersion.Xlsx
'Save the workbook to disk in xlsx format
workbook.SaveAs("Output.xlsx")
End Using