PowerQueryFormulaItemCollection.Item

PowerQueryFormulaItemCollection indexer (1 of 2)

Gets PowerQueryFormulaItem by the index in the list.

public PowerQueryFormulaItem this[int index] { get; }
ParameterDescription
indexThe index.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class PowerQueryFormulaItemCollectionPropertyItemDemo
    {
        public static void Run()
        {
            // Create a new workbook with a template that contains Power Query
            Workbook workbook = new Workbook();
            
            // Get the first Power Query formula (assuming one exists)
            var powerQueryFormula = workbook.DataMashup.PowerQueryFormulas[0];
            
            // Modify the formula items using Item property
            var formulaItems = powerQueryFormula.PowerQueryFormulaItems;
            if (formulaItems.Count > 0)
            {
                formulaItems[0].Value = "Sql.Database(\"SQL2K16\", \"EUC876REG\", [Query=\"select * from CANOTIFICATIONS\"])";
                
                // Verify the change
                Console.WriteLine(formulaItems[0].Value);
            }
            
            // Save the workbook
            workbook.Save("PowerQueryExample.xlsx");
        }
    }
}

See Also


PowerQueryFormulaItemCollection indexer (2 of 2)

Gets PowerQueryFormulaItem by the name of the item.

public PowerQueryFormulaItem this[string name] { get; }
ParameterDescription
nameThe name of the item.

See Also