Power Query Formulaアイテムの更新

使用シナリオ

データソースファイルが移動され、Excel ファイルがファイルを見つけられなくなる場合があります。そのような場合、Aspose.Cells for Python via .NET API は、PowerQueryFormulaItem クラスを使用してソースファイルの場所を更新し、Power Query の式アイテムを更新するオプションを提供します。

Power Query Formulaアイテムの更新

Aspose.Cells for Python via .NET API は、Power Query Formula Items の更新機能も提供します。次のコードスニペットは、PowerQueryFormulaItem.value プロパティを使用して Excel ファイル内のデータソースファイルの場所を更新する例です。参考のために、ソースと出力のファイルも添付されています。

サンプルコード

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Working directories
SourceDir = RunExamples.Get_SourceDirectory()
outputDir = RunExamples.Get_OutputDirectory()
workbook = Workbook(SourceDir + "SamplePowerQueryFormula.xlsx")
mashupData = workbook.data_mashup
for formula in mashupData.power_query_formulas:
for item in formula.power_query_formula_items:
if item.name == "Source":
item.value = "Excel.Workbook(File.Contents(\"" + SourceDir + "SamplePowerQueryFormulaSource.xlsx" + "\"), null, true)"
# Save the output workbook.
workbook.save(outputDir + "SamplePowerQueryFormula_out.xlsx")