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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to make a cell readonly in Excel?

Thread ID:

Created:

Updated:

Platform:

Replies:

150922 Jan 24,2020 10:10 AM UTC Jan 27,2020 12:55 PM UTC ASP.NET Core - EJ 2 1
loading
Tags: Spreadsheet
balaji
Asked On January 24, 2020 10:10 AM UTC

 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


Arunkumar Devendiran [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon