I have an excel sheet.
Want to make first 3 columns editable and remaining all columns non editable and blank (without grid lines) using c#. Please help...
Make excel columns non editable using c#
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Sunny SharmaRank #223 · 11.1K pointsPosted Aug 22, 2013, 10:23 PM EDT
You need to Unlock the whole sheet or the part which you want the user be able to edit and Lock the cells of your purpose.
Protect the sheet when you're done and that's all it takes.
try this way:
-----------------------------------------------------------
----------------------------------------------------------
Happy Coding :)
Cheers!!
Sanu22 pointsPosted Aug 25, 2013, 2:06 AM EDT
Dorothy Tincher10 pointsPosted May 9, 2014, 12:59 AM EDT
// Load excel file. var file = ExcelFile.Load("input.xlsx"); var sheet = file.Worksheets.ActiveWorksheet; // Set worksheet without grid lines. sheet.ViewOptions.ShowGridLines = false; // Set worksheet with protection. sheet.Protected = true; // Itarate through the required cells, set their borders and unlock them. var range = sheet.Cells.GetSubrange("A1", "C" + sheet.Rows.Count); foreach (var cell in range) { cell.SetBorders(MultipleBorders.Outside, Color.Black, LineStyle.Thin); cell.Style.Locked = false; } // Save excel file. file.Save("output.xlsx");