Çalışma Sayfasını veya Grafiği İstenilen Genişlik ve Yükseklikte Görüntüye Aktarın
Contents
[
Hide
]
Çalışma sayfanızı veya grafiğinizi istediğiniz genişlik ve yükseklikte bir görüntüye dışa aktarmak için Aspose.Cells’i kullanabilirsiniz. sağlarImageOrPrintOptions.SetDesiredSize() Dışa aktarılan görüntünün istenen genişliğini ve yüksekliğini ayarlama yöntemi. Genişlik ve yükseklik piksel biriminde belirtilir.
Aşağıdaki kod, çalışma sayfasını 400x400 boyutunda bir görüntüye aktarır.
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(); | |
// Create workbook object from source file | |
Workbook workbook = new Workbook(sourceDir + "sampleWorksheetToImageDesiredSize.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Set image or print options we want one page per sheet. The image format is in png and desired dimensions are 400x400 | |
Aspose.Cells.Rendering.ImageOrPrintOptions opts = new Aspose.Cells.Rendering.ImageOrPrintOptions(); | |
opts.OnePagePerSheet = true; | |
opts.ImageType = Drawing.ImageType.Png; | |
opts.SetDesiredSize(400, 400, false); | |
// Render sheet into image | |
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(worksheet, opts); | |
sr.ToImage(0, outputDir + "outputWorksheetToImageDesiredSize.png"); |