Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
Export the grid to Excel & make a few columns read only
posted

Hi All,

I have a requirement where after I export the grid to a excel, I need to make a few columns to be read only.

I actually have a functionality wherin the user exports the grid to a excel, makes changes to the excel and then imports back the data to the grid. All this works perfectly. Now i want to make a few columns read only so that the user cannot edit those columns.

Please help. Thanks in advance,

Bhagyashree

  • 5118
    Suggested Answer
    posted

    Looks like you want the Excel sheet columns read only? 

    If so you want to set the Locked state of the cells in question.  Remember the Locked state is ignored if the Worksheet is not Protected so set that too. 

    Also there is a resolution order:

    Cell formatting is associated with each cell, row, and column in a Worksheet. If a property of the cell format has a default value, the value of the previous format in resolution chain is used. The resolution priority is the following:

    1. Cell (highest priority)
    2. Row
    3. Column
    4. Default Cell Format (lowest priority)

    So you could set the Locked state on a Column but a Row or Cell can override that setting.  The Locked  setting.