Search code examples
excelonedriveazure-logic-appsazure-appservice

How to clear or remove the file data on Onedrive or Excel using Logic app?


I need to schedule for an everyday run, once it ran and sent a mail, the excel or onedrive data need to clear. enter image description here

enter image description here

updated each row from another logic app with the help of excel header.


Solution

  • I don't find an action in logic app or a rest api of excel which can delete all of the rows directly. So I think we can just loop "Delete a row" action to delete the rows one by one. Please refer to my logic app as below:

    1. First I use "List rows present in a table" action to list all of the rows. enter image description here

    2. Then my logic app show as this: enter image description here

    The "Condition" inside the "For each" is to judge if Column1 is null. If the value of Column1 is null, the "Delete a row" action will show error message.

    In "Delete a row" action, I choose Column1 as "Key Column" and put param Column1 into "Key Value" box. enter image description here

    3. After running the logic app, all of the rows will be deleted. You can add these steps under your "Send an email(v2)" action. Or if you want to do it in another logic app, you can use "When a new email arrives (V3)" as the trigger of the logic app.