Arbeitsblatt zu Bild Festlegen des Pixelformats für das gerenderte Bild
Contents
[
Hide
]
Manchmal möchten Sie das Pixelformat beim Rendern eines Arbeitsblatts im Bildformat angeben. Standardmäßig verwendet Aspose.Cells 32 Bits pro Pixel. Aspose.Cells ermöglicht es Ihnen, das Pixelformat (Bit-Tiefe) mit Optionen für das gerenderte Bild anzupassen.
Bitte beachten Sie den unten stehenden Beispielcode, der zeigt, wie das gewünschte Pixelformat beim Rendern von Blättern festgelegt wird.
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-.NET | |
//Source directory | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
//Output directory | |
string outputDir = RunExamples.Get_OutputDirectory(); | |
// Load an Excel file | |
Workbook wb = new Workbook(sourceDir + "sampleSetPixelFormatRenderedImage.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
// Set the ImageOrPrintOptions with desired pixel format (24 bits per pixel) and image format type | |
ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
opts.PixelFormat = PixelFormat.Format24bppRgb; | |
opts.ImageType = Drawing.ImageType.Tiff; | |
// Instantiate SheetRender object based on the first worksheet | |
SheetRender sr = new SheetRender(ws, opts); | |
// Save the image (first page of the sheet) with the specified options | |
sr.ToImage(0, outputDir + "outputSetPixelFormatRenderedImage.tiff"); |