EasyXLS

Protect Excel sheet

EasyXLS™ library enables you to protect and lock Excel cells and Excel sheet objects (images, charts, comments, etc.) in order to prevent editing or deleting the sheet elements.

The component also allows setting a sheet password for worksheets and chart sheets when protecting the Excel sheet elements. The password is optional. If set, the user cannot edit the sheet elements until the valid password is supplied.

EasyXLS also permits to protect formulas and hide formulas expressions.

Source code sample

The below example shows how to export data to Excel, protect Excel sheet and lock cells.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

The screen shot provides an example of an exported Excel file that has the sheet protected.

Protected Excel sheet

Locked cells

EasyXLS allows you to lock the Excel cells and prevent cell content and cell formatting to be edited using ExcelStyle.setLocked, ExcelCell.setLocked, ExcelColumn.setLocked and ExcelRow.setLocked methods.

Hidden formulas

EasyXLS allows you to hide the Excel formulas expressions using ExcelStyle.setHiddenFormula, ExcelCell.setHiddenFormula, ExcelColumn.setHiddenFormula and ExcelRow.setHiddenFormula methods.

The below source code sample shows how to hide formula expression from "A6 " cell. The sheet that contains the formula must be also protected.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

Protect sheet with password

EasyXLS allows you to protect the sheet with an optional password using ExcelSheet.setProtectionPassword method.

Protect Excel sheet objects

EasyXLS automatically protects the Excel sheet objects like images, charts, comments and other objects when the sheet is protected using ExcelSheet.setSheetProtected method.

In order to change this behavior use ExcelWorksheet.setAllowEditObjects method for worksheets or ExcelChartSheet.setProtectObjects for chart sheets.

Protect locked cells and unlocked cells selection

EasyXLS automatically allows the selection of cells when the sheet is protected using ExcelSheet.setSheetProtected method.

In order to change this behavior use ExcelWorksheet.setAllowSelectLockedCells and ExcelWorksheet.setAllowSelectUnlockedCells methods.

Protect cells, rows and columns formatting

EasyXLS does not automatically allow to format cells, rows or columns when the sheet is protected using ExcelSheet.setSheetProtected method.

In order to change this behavior use ExcelWorksheet.setAllowFormatCells, ExcelWorksheet.setAllowFormatRows or ExcelWorksheet.setAllowFormatColumns methods.

Protect rows and columns insertion

EasyXLS does not automatically allow to insert rows or columns when the sheet is protected using ExcelSheet.setSheetProtected method.

In order to change this behavior use ExcelWorksheet.setAllowInsertColumns or ExcelWorksheet.setAllowInsertRows methods.

Protect hyperlink insertion

EasyXLS does not automatically allow to insert hyperlinks when the sheet is protected using ExcelSheet.setSheetProtected method.

In order to change this behavior use ExcelWorksheet.setAllowInsertHyperlinks method.

Protect rows and columns deletion

EasyXLS does not automatically allow to delete rows or columns when the sheet is protected using ExcelSheet.setSheetProtected method.

In order to change this behavior use ExcelWorksheet.setAllowDeleteColumns or ExcelWorksheet.setAllowDeleteRows methods.

Protect sort and autofilter usage

EasyXLS does not automatically allow sorting and filtering worksheet data when the sheet is protected using ExcelSheet.setSheetProtected method.

In order to change this behavior use ExcelWorksheet.setAllowSort or ExcelWorksheet.setAllowUseAutofilter methods.

Protect pivot table and pivot chart usage

EasyXLS does not automatically allow to use pivot tables or pivot charts when the sheet is protected using ExcelSheet.setSheetProtected method.

In order to change this behavior use ExcelWorksheet.setAllowUsePivots method.

Protect worksheet scenarios

EasyXLS automatically protects the Excel worksheet scenarios when the sheet is protected using ExcelSheet.setSheetProtected method.

In order to change this behavior use ExcelWorksheet.setAllowEditScenarios method.

Protect chart sheet content

EasyXLS automatically protects the content of the chart sheet when the sheet is protected using ExcelSheet.setSheetProtected method.

In order to change this behavior use ExcelChartSheet.setProtectContents method.

Getting started with EasyXLS Excel library

To download the trial version of EasyXLS Excel Library, press the below button:

Download EasyXLS™ Excel Library for .NET and Java

If you already own a license key, you may login and download EasyXLS from your account.



Available for: Professional, Excel Writer, Excel Reader
Go to top

EasyXLS Excel libraries:

.NET
.NET Excel Library
full .NET version to import, export or convert Excel files
COM+ Excel Library
full COM+ version to import, export or convert Excel files
-
Java
Java Excel Library
full Java version to import, export or convert Excel files
Download EasyXLS™ Excel Library for .NET and Java

File formats:

Office 365
MS Excel 2021 - 2024
MS Excel 2007 - 2019
MS Excel 97 - 2003
XLSXXLSMXLSBXLS
XMLHTMLCSVTXT