Loading and saving workbook in Windows Forms
8 Dec 20231 minute to read
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");
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");