RealGrid2 Guide
Export to Excel 🆕
Excel sheet protection

Protect Excel sheet

You can set the lock function to prevent entering data into a cell or modifying the entered data.

For information related to sheet protection properties, please refer to the link below.
https://learn.microsoft.com/en-us/office/vba/api/excel.protection (opens in a new tab)

You can set cell-level locking by setting the style.

gridView.setCellStyleCallback(function(grd, model) {
     var ret = {cellProtectProps: {}};
     var colName = model.dataColumn && model.dataColumn.name;
     if (colName === "KorName") {
         ret.cellProtectProps.locked = "0";
     } else {
         ret.cellProtectProps.hidden = "1";
     }
     return ret;
});
 
 
gridView.exportGrid({
     type: "excel",
     target: "local",
     fileName: "gridExportSample.xlsx",
     sheetProtect: true, //Set sheet protection function
     protectPassword: '', //Specify password
     protectProperties: {
         formatCells:1, //"Format Cells"
         formatColumns:0, //"Format Columns"
         insertColumns:0, //"Insert column"
         formatRows:0, //"Format Rows"
         insertRows:0, //"Insert row"
         insertHyperlinks:0, //"Insert hyperlink"
         deleteColumns:0, //Delete column"
         deleteRows:0, //"Delete rows"
         sort:0, //"Sort"
         autoFilter:0, //"Use automatic filter"
         pivotTables:0, //"Use pivot table report"
         objects:0, //Edit object"
         scenarios:0, //"Edit scenario"
         selectLockedCells:1, //"Select locked cells"
         selectUnlockedCells:0 //"Select unlocked cells"
     },
     applyDynamicStyles: true;
     done: function () {
         //alert("done excel export")
     }
});