[]
Once you create a workbook, you can open the workbook to make modifications and save the changes back to the workbook.
This topic includes the following tasks:
You can open an existing workbook by calling the Open method of the Workbook class.
Refer to the following example code to open a workbook.
// Create a new workbook.
var workbook = new Workbook();
// Opening a workbook.
workbook.Open(@"Source.xlsx", OpenFileFormat.Xlsx);Note: While opening the workbook, you can check whether it is password protected or not by using the IsEncryptedFile method of the Workbook class. If your workbook is password protected, you would need to provide a password everytime you open it.
In addition to .xlsx files, you can also open the below file formats by using the overloads of Open method in Workbook class:
.xlsm
.xltx
.csv
.json
.ssjson
.sjs
An exception is thrown if you try to open an unsupported file format. For information about importing JSON, SSJSON, and SJS files with serialization options, see Import and Export SpreadJS Files.
For information about configuring import options when opening Excel files, see Excel Import Options.
You can save changes made to a workbook by calling the Save method of the Workbook class.
Refer to the following example code to save an Excel workbook.
// Save an excel file (.xlsx document)
workbook.Save("createWorkbook.xlsx");
// Saving an excel file with saveFileFormat.
workbook.Save(@"createWorkbook.xlsx", SaveFileFormat.Xlsx);In addition to .xlsx files, you can also save files in the below file formats by using the overloads of Save method in Workbook class:
.xlsm
.xltx
.csv
.html
.json
.ssjson
.sjs
For information about configuring export options when saving Excel files, see Excel Export Options.