Class PowerQueryFormulaItemCollection

PowerQueryFormulaItemCollection class

Represents all item of the power query formula.

public class PowerQueryFormulaItemCollection : CollectionBase<PowerQueryFormulaItem>

Properties

NameDescription
Capacity { get; set; }
Count { get; }
Item { get; }Gets PowerQueryFormulaItem by the index in the list. (2 indexers)
Item { get; set; }

Methods

NameDescription
BinarySearch(PowerQueryFormulaItem)
BinarySearch(PowerQueryFormulaItem, IComparer<PowerQueryFormulaItem>)
BinarySearch(int, int, PowerQueryFormulaItem, IComparer<PowerQueryFormulaItem>)
Clear()
Contains(PowerQueryFormulaItem)
CopyTo(PowerQueryFormulaItem[])
CopyTo(PowerQueryFormulaItem[], int)
CopyTo(int, PowerQueryFormulaItem[], int, int)
Exists(Predicate<PowerQueryFormulaItem>)
Find(Predicate<PowerQueryFormulaItem>)
FindAll(Predicate<PowerQueryFormulaItem>)
FindIndex(Predicate<PowerQueryFormulaItem>)
FindIndex(int, Predicate<PowerQueryFormulaItem>)
FindIndex(int, int, Predicate<PowerQueryFormulaItem>)
FindLast(Predicate<PowerQueryFormulaItem>)
FindLastIndex(Predicate<PowerQueryFormulaItem>)
FindLastIndex(int, Predicate<PowerQueryFormulaItem>)
FindLastIndex(int, int, Predicate<PowerQueryFormulaItem>)
GetEnumerator()
IndexOf(PowerQueryFormulaItem)
IndexOf(PowerQueryFormulaItem, int)
IndexOf(PowerQueryFormulaItem, int, int)
LastIndexOf(PowerQueryFormulaItem)
LastIndexOf(PowerQueryFormulaItem, int)
LastIndexOf(PowerQueryFormulaItem, int, int)
RemoveAt(int)

Examples

using System;
using Aspose.Cells;
using Aspose.Cells.QueryTables;

namespace AsposeCellsExamples
{
    public class QueryTablesClassPowerQueryFormulaItemCollectionDemo
    {
        public static void Run()
        {
            // Create a workbook with sample data
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            
            // Add sample Power Query data (simulated since we can't create actual PQ formulas programmatically)
            // Normally you would load an existing file with PQ formulas
            string sourcePath = "example.xlsm";
            try
            {
                workbook = new Workbook(sourcePath);
            }
            catch
            {
                Console.WriteLine("File not found. Using new workbook for demonstration.");
                return;
            }

            // Access Power Query Formulas
            PowerQueryFormulaCollection pqFormulas = workbook.DataMashup.PowerQueryFormulas;
            
            if (pqFormulas.Count > 0)
            {
                // Get first Power Query formula
                PowerQueryFormula formula = pqFormulas[0];
                Console.WriteLine("Formula Name: {0}", formula.Name);

                // Access formula items
                PowerQueryFormulaItemCollection items = formula.PowerQueryFormulaItems;
                Console.WriteLine("Number of items: {0}", items.Count);

                if (items.Count > 0)
                {
                    // Display first item
                    PowerQueryFormulaItem item = items[0];
                    Console.WriteLine("Item Name: {0}", item.Name);
                    Console.WriteLine("Item Value: {0}", item.Value);
                }
            }
            else
            {
                Console.WriteLine("No Power Query formulas found in the workbook.");
            }
        }
    }
}

See Also