# Open and Save Workbook

Learn how to open and save a workbook using DsExcel through sample codes.

## Content

After a workbook is created, you can open the workbook to incorporate modifications, save the changes back to the workbook and protect it with a password in order to ensure security.
This topic includes the following tasks:

* [Open a workbook](/document-solutions/java-excel-api/docs/online/v9.2/Features/ManageWorkbook/OpenSaveProtectWorkbook#open-a-workbook)
* [Save a workbook](/document-solutions/java-excel-api/docs/online/v9.2/Features/ManageWorkbook/OpenSaveProtectWorkbook#save-a-workbook)

## Open a workbook

You can open an existing workbook by calling the [open](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/Workbook.html#open) method of the [Workbook](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/Workbook.html#class-workbook) class.
Refer to the following example code to open a workbook.

```Java
// Create a new workbook.        
Workbook workbook = new Workbook();

// Opening a workbook.        
workbook.open("OpenWorkbook.xlsx");
```

>type=note
> **Note**: While opening the workbook, you can check whether it is password protected or not by using the [isEncryptedFile](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/Workbook.html#isencryptedfile) method of the Workbook class. If your workbook is password protected, you would need to provide a password everytime you open it.
> While opening a password protected excel file (version 2013 or later) in DsExcel Java, the illegal key size exception will be thrown. This happens because Java compiler supports 128 bit key and doesn't support the 256 bit key (Excel 2013 or later versions use 256 bit key) by default. In such a scenario, users can [apply the JCE unlimited strength policy files](https://www.oracle.com/java/technologies/javase/jceunlimitedstrghpolicyfilereadme.html) in order to resolve the issue.

In addition to .xlsx files, you can also open the below file formats by using the overloads of [open](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/Workbook.html#open) method in [Workbook](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/Workbook.html#class-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 Excel Files](/document-solutions/java-excel-api/docs/online/v9.2/ManageFileOperations/ImportandExportExcelOptions#excel-import-options).
For information about configuring import options when opening Excel files, see [Excel Import Options](/document-solutions/java-excel-api/docs/online/v9.2/ManageFileOperations/ImportandExportExcelOptions#excel-import-options).

## Save a workbook

You can save the changes made in the existing workbook by calling the [save](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/Workbook.html#save) method of the [Workbook](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/Workbook.html#class-workbook) class.
Refer to the following example code to save an Excel workbook.

```Java
// Saving an excel file (.xlsx document)
workbook.save("SaveExcel.xlsx");
        
// Saving an excel file with saveFileFormat
workbook.save("SaveExcelWithFormat.xlsx", SaveFileFormat.Xlsx);
```

In addition to .xlsx files, you can also save files in the below file formats by using the overloads of [save](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/Workbook.html#save) method in [Workbook](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/Workbook.html#class-workbook) class:

* .xlsm
* .xltx
* .csv
* .html
* .pdf
* .json
* .ssjson
* .sjs

For information about configuring export options when saving Excel files, see [Excel Export Options](/document-solutions/java-excel-api/docs/online/v9.2/ManageFileOperations/ImportandExportExcelOptions#excel-export-options).

## See Also

* [Import and Export Excel Files](/document-solutions/java-excel-api/docs/online/v9.2/ManageFileOperations/ImportandExportExcelOptions)
* [Import and Export SpreadJS Files](/document-solutions/java-excel-api/docs/online/v9.2/ManageFileOperations/ImportandExportSpreadJSFiles)
* [Import and Export CSV File](/document-solutions/java-excel-api/docs/online/v9.2/ManageFileOperations/ImportandExportCSVFile)
* [Cut or Copy Across Sheets](/document-solutions/java-excel-api/docs/online/v9.2/Features/ManageWorkbook/CutOrCopyAcrossSheets)