تحديث عنصر صيغة Power Query
Contents
[
Hide
]
سيناريو الاستخدام
قد تكون هناك حالات يتم فيها نقل ملفات مصدر البيانات ويكون ملف Excel غير قادر على تحديد موقع الملف. في مثل هذه الحالات ، يوفر Aspose.Cells API خيار تحديث عنصر صيغة Power Query باستخدامPowerQueryFormulaItem فئة لتحديث موقع الملف المصدر.
تحديث عنصر صيغة Power Query
يوفر Aspose.Cells API القدرة على تحديث عناصر صيغ Power Query. يوضح مقتطف التعليمات البرمجية التالي تحديث موقع ملف مصدر البيانات في ملف Excel باستخدام ملحقPowerQueryFormulaItem.Valueخاصية. ملفات المصدر والمخرجات المرفقة للرجوع اليها.
عينة من الرموز
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |