إدارة الصور في ورقة عمل
مضيفا الصور
لإضافة ارتباط تشعبي إلى خلية باستخدام Aspose.Cells.GridDesktop ، يرجى اتباع الخطوات التالية:
- أضف Aspose.Cells.GridDesktop control إلى ملفاستمارة
- الوصول إلى أي ملفاتورقة عمل
- يضيفصورة إلى ورقة العمل عن طريق تحديد مسار ملف الصورة واسم الخلية حيث سيتم إدراج الصورة
الصور جمع فيورقة عمل يوفر الكائن فوق طاقتهيضيف طريقة. يمكن للمطورين استخدام أي إصدار محمّل فوق طاقته منيضيف الطريقة وفقًا لاحتياجاتهم الخاصة. استخدام هذه الإصدارات المحملة بشكل زائد منيضيف الطريقة ، من الممكن إضافة صورة من ملف أو دفق أوصورة موضوع.
يوجد أدناه نموذج التعليمات البرمجية لإضافة الصور إلى أوراق العمل.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Accessing first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Adding picture to "b2" cell from file | |
sheet.Pictures.Add("b2", dataDir + "AsposeGrid.jpg"); | |
// Creating a stream contain picture | |
FileStream fs = new FileStream(dataDir + "AsposeLogo.jpg", FileMode.Open); | |
try | |
{ | |
// Adding picture to "b3" cell from stream | |
sheet.Pictures.Add(2, 1, fs); | |
} | |
catch (Exception ex) | |
{ | |
MessageBox.Show(ex.Message); | |
} | |
finally | |
{ | |
// Closing stream | |
fs.Close(); | |
} |
الوصول إلى الصور
للوصول إلى صورة موجودة في ورقة العمل وتعديلها ، يمكن للمطورين الوصول إلى الصورة من ملفالصور جمعورقة عمل من خلال تحديد الخلية (باستخدام اسم الخلية أو موقعها من حيث رقم الصف والعمود) التي يتم إدراج الصورة فيها. بمجرد الوصول إلى الصورة ، يمكن للمطورين تعديل صورتها في وقت التشغيل.
يوجد أدناه نموذج التعليمات البرمجية للوصول إلى الصور وتعديلها في ورقة العمل.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Accessing first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Accessing a picture added to "c3" cell (specified using its row & column number) | |
Aspose.Cells.GridDesktop.Data.GridPicture picture1 = sheet.Pictures[1]; | |
// Modifying the image | |
picture1.Image = Image.FromFile(dataDir + "Aspose.Grid.jpg"); |
إزالة الصور
لإزالة صورة موجودة ، يمكن للمطورين ببساطة الوصول إلى ورقة العمل المطلوبة وبعد ذلكيزيل صورة منالصور جمعورقة عمل بتحديد الخلية (باستخدام اسمها أو رقم الصف والعمود) التي تحتوي على الصورة.
يظهر في الكود أدناه كيفية إزالة الصور من ورقة العمل.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Removing picture from "c3" cell | |
sheet.Pictures.Remove(2, 2); |