استخراج الصور من أوراق العمل باستخدام ImageOrPrintOptions
Contents
[
Hide
]
Microsoft يمكن لمستخدمي Excel إضافة صور إلى جداول البيانات. باستخدام Aspose.Cells ، يمكن قراءة الصور من Microsoft ملفات Excel وحفظها على محرك أقراص محلي. يوضح هذا المقال كيف.
يوضح نموذج التعليمات البرمجية أدناه كيفية استخراج الصور من ملف Excel وحفظها.
This file contains hidden or 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(); | |
// Open a template Excel file | |
Workbook workbook = new Workbook(sourceDir + "sampleExtractImagesFromWorksheets.xlsx"); | |
// Get the first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Get the first Picture in the first worksheet | |
Aspose.Cells.Drawing.Picture pic = worksheet.Pictures[0]; | |
// Set the output image file path | |
string picformat = pic.ImageType.ToString(); | |
// Note: you may evaluate the image format before specifying the image path | |
// Define ImageOrPrintOptions | |
ImageOrPrintOptions printoption = new ImageOrPrintOptions(); | |
// Specify the image format | |
printoption.ImageType = Drawing.ImageType.Jpeg; | |
// Save the image | |
pic.ToImage(outputDir + "outputExtractImagesFromWorksheets.jpg", printoption); |