إضافة روابط فائقة النص للصور
Contents
[
Hide
]
الروابط الفائقة مفيدة للوصول إلى المعلومات في ورق العمل الآخر، أو على المواقع الإلكترونية. يتيح Microsoft Excel للمستخدمين إضافة روابط فائقة للنص في الخلايا، وعلى الصور. يمكن أن تجعل روابط الصور التنقل في ورق العمل أسهل، على سبيل المثال، كزر الإرجاع والإلى الأمام، أو شعارات ترتبط بمواقع معينة. يشرح هذا المستند كيفية إدراج روابط الصور في ورق عمل باستخدام Aspose.Cells.
يسمح Aspose.Cells بإضافة روابط فائقة للصور في جداول البيانات أثناء التشغيل. من الممكن تعيين وتعديل نص الشاشة والعنوان الخاص بالرابط.
يوضح الكود العيني التالي كيفية إضافة رابط فائق للصورة في ورقة العمل.
عند تشغيل الكود، يقوم بحفظ ملف الإخراج برابط فائق للصورة فيه.
ملف الإخراج
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 | |
String dataDir = Utils.getDataDir(AddImageHyperlinks.class); | |
// Instantiate a new workbook | |
Workbook workbook = new Workbook(); | |
// Get the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Insert a string value to a cell | |
worksheet.getCells().get("C2").setValue("Image Hyperlink"); | |
// Set the 4th row height | |
worksheet.getCells().setRowHeight(3, 100); | |
// Set the C column width | |
worksheet.getCells().setColumnWidth(2, 21); | |
// Add a picture to the C4 cell | |
int index = worksheet.getPictures().add(3, 2, 4, 3, dataDir + "aspose-logo.jpg"); | |
// Get the picture object | |
com.aspose.cells.Picture pic = worksheet.getPictures().get(index); | |
// Set the placement type | |
pic.setPlacement(PlacementType.FREE_FLOATING); | |
// Add an image hyperlink | |
pic.addHyperlink("http://www.aspose.com/"); | |
com.aspose.cells.Hyperlink hlink = pic.getHyperlink(); | |
// Specify the screen tip | |
hlink.setScreenTip("Click to go to Aspose site"); | |
// Save the Excel file | |
workbook.save(dataDir + "ImageHyperlink.xls"); |