Güç Sorgusu Formül Öğesini Güncelle

Kullanım Senaryosu

Veri kaynağı dosyalarının taşındığı ve excel dosyasının dosyayı bulamadığı durumlar olabilir. Bu gibi durumlarda, Aspose.Cells API’siPowerQueryFormulaItem sınıfını kullanarak Power Query Formül öğesini güncelleme seçeneği sunar.

Power Query Formül Öğesini Güncelleme

Aspose.Cells API’si, Power Query Formül öğelerini güncelleme olanağı sunar. Aşağıdaki kod örneği, excel dosyasındaki veri kaynağı dosya konumunun güncellenmesini PowerQueryFormulaItem.Value özelliğini kullanarak göstermektedir. Referansınız için kaynak ve çıktı dosyaları ekte sunulmuştur.

Örnek Kod

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Working directories
string SourceDir = RunExamples.Get_SourceDirectory();
string outputDir = RunExamples.Get_OutputDirectory();
Workbook workbook = new Workbook(SourceDir + "SamplePowerQueryFormula.xlsx");
DataMashup mashupData = workbook.DataMashup;
foreach (PowerQueryFormula formula in mashupData.PowerQueryFormulas)
{
foreach (PowerQueryFormulaItem item in formula.PowerQueryFormulaItems)
{
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");