Write Cell with password protected excel

When I use the Write Cell activity to write to a spreadsheet that is password protected I get errors. The edition of Excel that the file was saved is Microsoft Office Professional Plus 2016.

At the Save dialog we have the Tools, General Options... to set password for opening or for modifying the spreadsheet.
When setting a password for opening, it gives the error File contains corrupted data.
When setting a password for modifying, it gives the error:

System.IO.FileFormatException: Input file or data stream does not conform to the expected file format specification.
   at UiPath.Excel.Encryption.OfficeCryptography.DecryptFile(String filePath, String password, Stream outputStream)
   at UiPath.Excel.WorkbookFile..ctor(String workbookPath, String password, Boolean createNew)
   at UiPath.Excel.Activities.WorkbookActivity`1.ConstructWorkbook(String path, String password, Boolean createNew)
   at UiPath.Excel.Activities.WorkbookActivity`1.BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, Object state)
   at System.Activities.AsyncCodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

How should I write to a password protected excel’s cell with the Write Cell activity? Other activities, workarounds without rewriting the whole document / loosing its protection?

updateExcel.zip (150.6 KB)

Excel application scope activity has property called password enter excel file password into that field and within the scope use write cell activity.

Regards,
Mahaling Patil

1 Like

Thanks that is a good workaround, it does work. But any idea what does the Write Cell’s password field do if not this that I want here?

@obeliksz,

Please check below thread. May be it will helpful to you.

Problem with Password Protected Excel file