Class PowerQueryFormulaItem

PowerQueryFormulaItem class

Represents the item of the power query formula.

public class PowerQueryFormulaItem

Properties

NameDescription
Name { get; }Gets the name of the item.
Value { get; set; }Gets the value of the item.

Examples

namespace AsposeCellsExamples
{
    using System;
    using Aspose.Cells;
    using Aspose.Cells.QueryTables;

    public class QueryTablesClassPowerQueryFormulaItemDemo
    {
        public static void Run()
        {
            try
            {
                // Create a new workbook (can be an existing file if you have Power Query data)
                Workbook workbook = new Workbook();

                // Access the DataMashup object which contains PowerQuery formulas
                DataMashup mashup = workbook.DataMashup;

                bool itemFound = false;

                // Iterate through all PowerQuery formulas and their items
                foreach (PowerQueryFormula formula in mashup.PowerQueryFormulas)
                {
                    foreach (PowerQueryFormulaItem item in formula.PowerQueryFormulaItems)
                    {
                        // Demonstrate read‑only Name property
                        Console.WriteLine($"Item Name: {item.Name}");

                        // Demonstrate read/write Value property
                        Console.WriteLine($"Original Value: {item.Value}");
                        item.Value = "SampleValue";
                        Console.WriteLine($"Modified Value: {item.Value}");

                        itemFound = true;
                    }
                }

                if (!itemFound)
                {
                    Console.WriteLine("No PowerQueryFormulaItem instances were found in the workbook.");
                }

                Console.WriteLine("PowerQueryFormulaItem demo completed successfully.");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error working with PowerQueryFormulaItem: {ex.Message}");
            }
        }
    }
}

See Also