An Azure service for ingesting, preparing, and transforming data at scale.
Hello @Yernaidu Siraparapu ,
Yes, this can be automated, but the recommended approach depends on whether you know the worksheet protection password and are authorized to remove it.
If the password is known, the best approach is usually:
- Download the
.xlsmfile from SharePoint - Use an Azure Function to open the workbook and remove worksheet protection using the known password
- Save the workbook back in
.xlsmformat - Upload/copy the updated file to ADLS Gen2
Azure Data Factory, Logic Apps, and Power Automate are good for orchestration and file movement, but they are not ideal for modifying Excel worksheet protection inside an .xlsm file. ADF’s SharePoint Online List connector is primarily for SharePoint list data, not direct Excel file manipulation, and Microsoft Graph is commonly used to download SharePoint/OneDrive file content programmatically.
For the SharePoint file access part, you can use Microsoft Graph API to download the file content from SharePoint/OneDrive. Microsoft Graph supports downloading a driveItem using endpoints such as: GET /sites/{site-id}/drive/items/{item-id}/content
https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0
For copying the final file to ADLS Gen2, you can use the Azure Storage SDK from the Azure Function or use ADF after the file has already been processed. ADF is suitable for pipeline orchestration and copy activities, but the actual Excel modification should be handled in code, such as an Azure Function.
- If you do not know the password, Microsoft services will not provide a supported way to bypass or crack the worksheet protection. You should obtain the password from the file owner or ask the owner to provide an unprotected version.
- Avoid using Excel desktop automation/COM automation in Azure Functions, as it is not suitable for server-side automation.
- Use a library that supports
.xlsmand can preserve macros while modifying only the worksheet protection setting. - Make sure the Azure Function identity or app registration has appropriate permissions to read the SharePoint file and write to ADLS.
If this answer was helpful, please consider accepting it as the answer. If you have any questions or need further clarification, please comment on this thread and I will be happy to assist.