Worksheet Row to be read only with out protection

Hi.

I am wroking on the Worksheet . i just need help ifor "in Worksheet i need only Row to be read only and rest can be editable ".


This message was posted using Aspose.Live 2 Forum

Hi,

Yes, you may protect your desired row in a worksheet using Aspose.Cells, see the document:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/protecting-worksheets.html

(Note: see the sub-topic: “Protect a Row in the Worksheet”).

Thank you.

Thanks for your reply.

But my problem is the whole worksheet is getting protected and not allowing to make changes in the other Rows whch i haven't Locked.But i need only Couple of Rows to be locked and not allow user to edit them and rest of the rows should be in editable.So that user can enter some data aganist it


This message was posted using Email2Forum by GeorgeClark.

Hi,

As I suggested you the document earlier to check, if you could see my suggested code sample under “Protect a Row in the Worksheet” sub-topic, the code correctly locks a single row (first row) in the worksheet, other rows can be edited and you may put values to the other rows. I will paste the code from the document here for your reference:

// Create a new workbook.


Workbook wb = new Workbook();



// Create a worksheet object and obtain the first sheet.


Worksheet sheet = wb.Worksheets[0];



// Define the style object.


Style style;



// Define the styleflag object.


StyleFlag flag;



// Loop through all the columns in the worksheet and unlock them.


for (int i = 0; i <= 255; i++)


{


style = sheet.Cells.Columns[(byte)i].Style;


style.IsLocked = false;


flag = new StyleFlag();


flag.Locked = true;


sheet.Cells.Columns[(byte)i].ApplyStyle(style, flag);



}



// Get the first row style.


style = sheet.Cells.Rows[0].Style;



// Lock it.


style.IsLocked = true;



// Instantiate the flag.


flag = new StyleFlag();



// Set the lock setting.


flag.Locked = true;



// Apply the style to the first row.


sheet.Cells.ApplyRowStyle(0, style, flag);



// Protect the sheet.


sheet.Protect(ProtectionType.All);



// Save the excel file.


wb.Save(“d:\test\lockedrow.xls”, SaveFormat.Excel97To2003);