We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to make a cell readonly in Excel?

 How do I make a complete sheet as read-only and for some sheet i want to make certain coloums as read only. how to do that using syncfusion


1 Reply

AD Arunkumar Devendiran Syncfusion Team January 27, 2020 12:55 PM UTC

Hi Balaji, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your query and it can be achieved by using “cellEdit” event. We have create a sample to behave certain column cells as readonly by using args.cancel in cellEdit event. In this sample we have set the sheet1 cells are read only and the specific column (‘A’) as read only on sheet2. Please refer the below code snippet and sample link. 
 
Index.cshtml 
 
<ejs-spreadsheet id="spreadsheet" cellEdit="onCellEdit"> 
    <e-spreadsheet-sheets> 
        <e-spreadsheet-sheet> 
            <e-spreadsheet-rangesettings> 
                <e-spreadsheet-rangesetting dataSource="ViewBag.DefaultData"></e-spreadsheet-rangesetting> 
            </e-spreadsheet-rangesettings> 
        </e-spreadsheet-sheet> 
        <e-spreadsheet-sheet> 
            <e-spreadsheet-rangesettings> 
                <e-spreadsheet-rangesetting dataSource="ViewBag.DefaultData"></e-spreadsheet-rangesetting> 
            </e-spreadsheet-rangesettings> 
        </e-spreadsheet-sheet> 
    </e-spreadsheet-sheets> 
</ejs-spreadsheet> 
<script> 
    function onCellEdit(args) { 
        if (this.activeSheetTab === 1) { 
            args.cancel = true; 
        } 
        if (this.activeSheetTab === 2) { 
            var i = args.address.indexOf("!") + 1; 
            var colIndex = []; 
            var address = args.address.substr(i, args.address.length); 
            colIndex = ejs.spreadsheet.getCellIndexes(address); 
            console.log(colIndex); 
            var col = 0; 
            if (col === colIndex[1]) { 
                args.cancel = true; 
            } 
        } 
    } 
</script> 
 
 
Sample link: 
 
Please get back to us if you need further assistance. 
 
Regards, 
Arunkumar D 


Loader.
Live Chat Icon For mobile
Up arrow icon