قم بتحديث قيم الأشكال المرتبطة
Contents
[
Hide
]
في بعض الأحيان ، يكون لديك شكل مرتبط في ملف Excel مرتبط ببعض الخلايا. في Microsoft Excel ، يؤدي تغيير قيمة الخلية المرتبطة أيضًا إلى تغيير قيمة الشكل المرتبط. يعمل هذا أيضًا بشكل جيد مع Aspose.Cells إذا كنت تريد حفظ المصنف بتنسيق XLS أو XLSX. ومع ذلك ، إذا كنت تريد حفظ المصنف بتنسيق PDF أو HTML ، فسيتعين عليك الاتصالWorksheet.getShapes (). updateSelectedValue () طريقة لتحديث قيمة الشكل المرتبط.
مثال
تُظهر لقطة الشاشة التالية ملف Excel المصدر المستخدم في نموذج التعليمات البرمجية أدناه. لها ارتباطالصورة 1 مرتبط بالخلية A1. سنقوم بتغيير قيمة الخلية A1 مع Aspose.Cells ثم الاتصالWorksheet.getShapes (). updateSelectedValue () طريقة لتحديث قيمةالصورة 1 وحفظه بتنسيق PDF.
يمكنك تنزيل ملفملف Excel المصدر و الالإخراج PDF من الروابط المعطاة.
كود Java لتجديد قيم الأشكال المرتبطة
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-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RefreshValuesOfLinkedShapes.class); | |
// Create workbook from source file | |
Workbook workbook = new Workbook(dataDir + "LinkedShape.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Change the value of cell A1 | |
Cell cell = worksheet.getCells().get("A1"); | |
cell.putValue(100); | |
// Update the value of the Linked Picture which is linked to cell A1 | |
worksheet.getShapes().updateSelectedValue(); | |
// Save the workbook in pdf format | |
workbook.save(dataDir + "output.pdf", SaveFormat.PDF); |