Skapa transparent bild av Excel-kalkylblad
Contents
[
Hide
]
Ibland måste du skapa bilden av ditt kalkylblad som en transparent bild. Du vill tillämpa genomskinlighet på alla celler som inte har några fyllningsfärger. Aspose.Cells tillhandahållerImageOrPrintOptions.Transparentegenskap för att tillämpa transparens på kalkylbladsbilden. När denna fastighet ärfalsk , sedan ritas celler utan fyllningsfärger med vit färg och när det är detSann, celler utan fyllningsfärger ritas genomskinliga.
I följande kalkylbladsbild har inte genomskinlighet tillämpats. Cellerna utan fyllningsfärger ritas vita.
Utdata utan genomskinlighet: cellbakgrunden är vit |
---|
![]() |
I följande kalkylbladsbild har genomskinlighet tillämpats. Cellerna utan fyllningsfärger är genomskinliga.
Utdata med öppenhet aktiverad |
---|
![]() |
Följande exempelkod genererar en transparent bild från ett Excel-kalkylblad.
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(); | |
// 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"); |