i want to apply password to the excel but office is not installed in prod. machine so cant use excel application scope.
Also cant use any external package from manage packages.
is their any way i can achieve it.
zip an excel and apply password to zip folder is my current approach but it is not working when we need to edit content in the excel.After editing manually need to apply password.as password is initially applied on zip and not on excel
You can try using the Invoke Code activity to manipulate the Excel file. You’ll need the OpenXML library since Excel isn’t installed. If Excel were installed, you’d be able to use Interops.Excel. VB Code.txt (670 Bytes)
Is your original file too much formatted or have just the data. If not formatted, you can use Read Range activity to read the data and write range to write it to another file with password.
@J0ska
thanks for reply.
due to environment restriction, i am not able to upload any external package.
Microsoft office is not present .
I want to apply password to existing excel
this can be achieved by “ClosedXML” package that is a dependency of UiPath.Excel.Activities
e.g. following code can be used for it:
xls = New ClosedXML.Excel.XLWorkbook("protect.xlsx")
Dim sheet = xls.Worksheet("Sheet1")
Dim prot = sheet.Protect("123")
prot.AllowedElements = XLSheetProtectionElements.InsertRows Or XLSheetProtectionElements.InsertColumns
xls.SaveAs("protect.xlsx")