1

I am using EPPlus to read data from .XLSX file.

issue is it is not able to read locked cells. So I have to open excel, Unlock cells, and then upload. Is there way to read lock cells. I tried as below:

 For row As Integer = workSheet.Dimension.Start.Row + 1 To workSheet.Dimension.[End].Row
            workSheet.Cells(row, vLocation).Style.Locked = False
            Dim strLocation = Convert.ToString(workSheet.Cells(row, vLocation).Value)

 Next

Even i tried following code to unlock the worksheet with EPPlus

    Try
        workSheet.Protection.IsProtected = False
        workSheet.Cells("A1:Z200").Style.Locked = False
    Catch ex As Exception
    End Try

But it does not work. If I unlock cells manually and upload file then it works.

enter image description here

otherwise following line returns nothing

Dim strLocation = Convert.ToString(workSheet.Cells(row, vLocation).Value)
user2739418
  • 1,623
  • 5
  • 29
  • 51
  • I assume the sheet has protection turned on (otherwise locking a cell should have no effect). Is the sheet lock password protected? Either way it works fine for me. Maybe post more of your code or post the file somewhere. – Ernie S Jun 09 '16 at 14:21

1 Answers1

-1

Please try this.

 Dim fileInfo = new FileInfo(filePath);
    using (var package = new ExcelPackage(fileInfo))
    {
       Dim ws = package.Workbook.Worksheets.FirstOrDefault();
       Dim value = ws.Cells[Row, Col].Value;
    }