Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: proctect/lock specific cells

$
0
0
this is what I got
        XLWorkbook workbook = new XLWorkbook();
        IXLWorksheet ixlWorksheet = workbook.AddWorksheet("lock test");

        //set values
        ixlWorksheet.Row(1).Cell(1).SetValue("P1");
        ixlWorksheet.Row(1).Cell(2).SetValue("P2");
        ixlWorksheet.Row(1).Cell(3).SetValue("P3");
        ixlWorksheet.Row(1).Cell(4).SetValue("P4");
        ixlWorksheet.Row(1).Cell(5).SetValue("P5");
        ixlWorksheet.Row(1).Cell(6).SetValue("6"); 
        
        //protect
        ixlWorksheet.SelectedRanges.Add(ixlWorksheet.Range(1, 1, 1, 5));
        ixlWorksheet.Protect().SetSelectLockedCells(true);
        ixlWorksheet.SelectedRanges.Clear();
this is what I have so far but it locks all cells on the sheet, and cells 1 -> 5 values are not shown

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>