قم بتحديث قيم الأشكال المرتبطة
Contents
[
Hide
]
في بعض الأحيان ، يكون لديك شكل مرتبط في ملف Excel مرتبط ببعض الخلايا. في Microsoft Excel ، يؤدي تغيير قيمة الخلية المرتبطة أيضًا إلى تغيير قيمة الشكل المرتبط. يعمل هذا أيضًا بشكل جيد مع Aspose.Cells إذا كنت تريد حفظ المصنف بتنسيق XLS أو XLSX. ومع ذلك ، إذا كنت تريد حفظ المصنف بتنسيق PDF أو HTML ، فسيتعين عليك الاتصالورقة العمل الأشكال. UpdateSelectedValue () طريقة لتحديث قيمة الشكل المرتبط.
مثال
تُظهر لقطة الشاشة التالية ملف Excel المصدر المستخدم في نموذج التعليمات البرمجية أدناه. لها صورة مرتبطة بالخلايا A1 إلى E4. سنقوم بتغيير قيمة الخلية B4 مع Aspose.Cells ثم الاتصالورقة العمل الأشكال. UpdateSelectedValue ()طريقة لتحديث قيمة الصورة وحفظها بتنسيق PDF.
يمكنك تنزيل ملفملف Excel المصدر و الالإخراج PDF من الروابط المعطاة.
كود C# لتجديد قيم الأشكال المرتبطة
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 | |
//Source directory | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
//Output directory | |
string outputDir = RunExamples.Get_OutputDirectory(); | |
// Create workbook from source file | |
Workbook workbook = new Workbook(sourceDir + "sampleRefreshValueOfLinkedShapes.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Change the value of cell B4 | |
Cell cell = worksheet.Cells["B4"]; | |
cell.PutValue(100); | |
// Update the value of the Linked Picture which is linked to cell B4 | |
worksheet.Shapes.UpdateSelectedValue(); | |
// Save the workbook in PDF format | |
workbook.Save(outputDir + "outputRefreshValueOfLinkedShapes.pdf", SaveFormat.Pdf); |