Crear una imagen transparente de la hoja de cálculo de Excel
En la siguiente imagen de hoja de cálculo, no se ha aplicado transparencia. Las celdas sin colores de relleno se dibujan en blanco.
Salida sin transparencia: el fondo de la celda es blanco |
---|
![]() |
Mientras que, en la siguiente imagen de la hoja de trabajo, se ha aplicado transparencia. Las celdas sin colores de relleno son transparentes.
Salida con transparencia habilitada |
---|
![]() |
El siguiente código de ejemplo genera una imagen transparente a partir de una hoja de cálculo de Excel.
// 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 wb = new Workbook(sourceDir + "sampleCreateTransparentImage.xlsx"); | |
// Apply different image or print options | |
var imgOption = new ImageOrPrintOptions(); | |
imgOption.ImageType = Drawing.ImageType.Png; | |
imgOption.HorizontalResolution = 200; | |
imgOption.VerticalResolution = 200; | |
imgOption.OnePagePerSheet = true; | |
// Apply transparency to the output image | |
imgOption.Transparent = true; | |
// Create image after apply image or print options | |
var sr = new SheetRender(wb.Worksheets[0], imgOption); | |
sr.ToImage(0, outputDir + "outputCreateTransparentImage.png"); |