Removing Query from Workbook

Hello,

I am trying to delete a power query through Aspose.Cells but am unable to find a way to do it. I’ve tried removing the data connections, but this does not remove the query.

This is the Excel behaviour I am trying to mimic in particular:

In the top ribbon, go to Data Queries and Connections → hover mouse over query in the right side-bar and delete the query.

Thank you.

@danilolekovic ,

Could you please zip and attach your sample Excel file containing the power queries which you want to remove? We will check it soon.

Hi Amjad, I figured it out just now. Thanks!

DataMashup mashupData = workbook.DataMashup;
foreach (PowerQueryFormula formula in mashupData.PowerQueryFormulas)
{
    foreach (PowerQueryFormulaItem item in formula.PowerQueryFormulaItems)
    {
        item.Value = null;
    }
}

@danilolekovic
Thanks for your feedback and details. I’m glad your issue has been solved. If you have any questions, please feel free to contact us.