إدارة الصور
Contents
[
Hide
]
Aspose.Cells يسمح للمطورين بإضافة الصور إلى جداول البيانات في وقت التشغيل. علاوة على ذلك ، يمكن التحكم في موضع هذه الصور في وقت التشغيل ، وهو ما سيتم مناقشته بمزيد من التفصيل في الأقسام القادمة.
Aspose.Cells for Java يدعم فقط تنسيقات الصور: BMP ، JPEG ، PNG ، GIF.
الفهارس المستخدمة في الأمثلة تبدأ من 0.
مضيفا الصور
من السهل جدًا إضافة الصور إلى جدول البيانات. لا يتطلب الأمر سوى بضعة أسطر من التعليمات البرمجية.
ما عليك سوى الاتصال بـيضيف طريقة الالصور مجموعة (مغلفة في ملفورقة عمل موضوع). اليضيف تأخذ الطريقة المعلمات التالية:
- فهرس الصف العلوي الأيسر، فهرس الصف العلوي الأيسر.
- فهرس العمود الأيسر العلوي، فهرس العمود الأيسر العلوي.
- اسم ملف الصورة، اسم ملف الصورة ، كامل مع المسار.
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(AddingPictures.class); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
// Obtaining the reference of first worksheet | |
Worksheet sheet = worksheets.get(0); | |
// Adding a picture at the location of a cell whose row and column indices are 5 in the worksheet. It is "F6" cell | |
int pictureIndex = sheet.getPictures().add(5, 5, dataDir + "logo.jpg"); | |
Picture picture = sheet.getPictures().get(pictureIndex); | |
// Saving the Excel file | |
workbook.save(dataDir + "book1.xls"); |
وضع الصور
يمكن وضع الصور باستخدام Aspose.Cells على النحو التالي:
تحديد المواقع المطلقة
يمكن للمطورين وضع الصور تمامًا باستخدام ملفsetUpperDeltaX وsetUpperDeltaY طرقصورةموضوع.
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(AbsolutePositioning.class); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of the newly added worksheet. | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
// Adding a picture at the location of a cell whose row and column indices are 5 in the worksheet. It is "F6" cell | |
int pictureIndex = worksheet.getPictures().add(5, 5, dataDir + "logo.jpg"); | |
Picture picture = worksheet.getPictures().get(pictureIndex); | |
// Positioning the picture proportional to row height and colum width | |
picture.setUpperDeltaX(200); | |
picture.setUpperDeltaY(200); | |
// Saving the Excel file | |
workbook.save(dataDir + "test_pictures.xls"); |