Aggiornare l Elemento della Formula di Power Query

Scenario di Utilizzo

Potrebbero esserci casi in cui i file della fonte dati vengono spostati e il file Excel non riesce a trovarli. In tali casi, l’API Aspose.Cells per Python via .NET fornisce l’opzione di aggiornare l’elemento Power Query Formula usando la classe PowerQueryFormulaItem per aggiornare la posizione del file sorgente.

Aggiornare l’Elemento della Formula Power Query

L’API Aspose.Cells per Python via .NET fornisce la possibilità di aggiornare gli elementi Power Query Formula. Il seguente esempio di codice dimostra come aggiornare la posizione del file sorgente dei dati nel file Excel usando la proprietà PowerQueryFormulaItem.value. I file di origine e di output sono allegati per il tuo riferimento.

Codice di Esempio

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")