Lock image (or picture) or Get image (or picture) from excel using EPPlus

Viewed 1525

I'm using EPPlus for excel export. In that, I've locked image. Through code before insert some values to cells, I've unprotect sheet data or cells.

After unprotect, I've inserted values and locked those cells and then applied protection. For the cells which have data are locked. But the image has unlocked.

Now I'm having only two solution.

  1. How to keep the image (or picture) has locked in sheet.
  2. How to get the image (or picture) from excel and insert that image as embedded.

How to do that ? Here i've given my code.

// If worksheet has protection already, then need to unprotect
                    if (workSheet.Protection.IsProtected)
                        workSheet.Protection.IsProtected = false;
                    else
                        workSheet.Cells.Style.Locked = false;


workSheet.Cells[rowIndex, columnIndex].value="Test";
workSheet.Cells[rowIndex, columnIndex].Style.Locked=true;

// Protect the sheet after cells locked
                    workSheet.Protection.IsProtected = true;
                    workSheet.Protection.SetPassword(BasReportPassword);
                    workSheet.Protection.AllowSelectLockedCells = true;
                    workSheet.Protection.AllowSelectUnlockedCells = true;
                    excelPackage.Save();
1 Answers
Related