.net – How to ignore password protected excel sheets programmatically

excelvb.net

With my Tool we are scanning excel files and generating reports. My problem is some excel sheets are password protected and getting pup-up while scanning and it halts the Tool to run further.

Could someone let me know the solution, how to overcome with this problem. I just need to skip the sheet and continue with scanning without any user intervention.

Thank You,

Sugam

Best Answer

The workbook has a HasPassword property i.e. (C#):

Workbook book = GetYourWorkbook();
if (book.HasPassword)
{
  // Ignore!
}
else
{
  // Perform your operations here
}
Related Topic