Good evening dear community,
I hope that you all are ok.
I have a question about Power PLC.
I have an excel file that has a lot of sheets. I would only like two sheets in a new file but I can't.
I found a solution by hiding the sheets but we always know them and for security reasons this should not be possible.
Is it possible to designate the sheets to export to an Excel file via Power automaton or if you have another solution ...
Thank you in advance.
Solved! Go to Solution.
Hello @Milozebre74 ,
Wondering if you can give the new "Run script" action of the Excel Online (Business) connector a try.
This new action can run a script (Office Scripts) in Power Automate against a workbook. Office Scripts can do many tasks including deleting worksheets, which probably can solve the problem you mentioned here.
Here is a sample script that can delete all the worksheets in the workbook except for "Sheet 1" and "Sheet 2":
function main(workbook: ExcelScript.Workbook) {
const sheetsToKeep = ["Sheet1", "Sheet2"];
const allSheets = workbook.getWorksheets();
allSheets.forEach(sheet => {
if (!sheetsToKeep.includes(sheet.getName())) {
sheet.delete();
}
});
}
Here are a few links that might be helpful to learn about using Office Scripts with Power Automate:
Hope this helps!
Yutao
Hello @Milozebre74 ,
Wondering if you can give the new "Run script" action of the Excel Online (Business) connector a try.
This new action can run a script (Office Scripts) in Power Automate against a workbook. Office Scripts can do many tasks including deleting worksheets, which probably can solve the problem you mentioned here.
Here is a sample script that can delete all the worksheets in the workbook except for "Sheet 1" and "Sheet 2":
function main(workbook: ExcelScript.Workbook) {
const sheetsToKeep = ["Sheet1", "Sheet2"];
const allSheets = workbook.getWorksheets();
allSheets.forEach(sheet => {
if (!sheetsToKeep.includes(sheet.getName())) {
sheet.delete();
}
});
}
Here are a few links that might be helpful to learn about using Office Scripts with Power Automate:
Hope this helps!
Yutao
User | Count |
---|---|
25 | |
15 | |
14 | |
10 | |
9 |
User | Count |
---|---|
49 | |
29 | |
28 | |
25 | |
23 |