Rendre la feuille de calcul dans le contexte graphique

Contents
[ ]

Le code suivant illustre comment utiliser Aspose.Cells pour afficher la feuille de calcul dans un contexte graphique. Une fois que vous aurez exécuté un code, il imprimera toute la feuille de calcul et remplira l’espace vide restant avec une couleur bleue dans le contexte graphique et enregistrera l’image sous**OutputImage_out_.png** dossier. Vous pouvez utiliser n’importe quel fichier Excel source pour essayer ce code. Veuillez également lire les commentaires à l’intérieur du code pour une meilleure compréhension.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create workbook object from source file
Workbook workbook = new Workbook(dataDir + "SampleBook.xlsx");
// Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Create empty Bitmap
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(1100, 600);
// Create Graphics Context
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
g.Clear(System.Drawing.Color.Blue);
// Set one page per sheet to true in image or print options
Aspose.Cells.Rendering.ImageOrPrintOptions opts = new Aspose.Cells.Rendering.ImageOrPrintOptions();
opts.OnePagePerSheet = true;
// Render worksheet to graphics context
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(worksheet, opts);
sr.ToImage(0, g, 0, 0);
// Save the graphics context image in Png format
bmp.Save(dataDir + "OutputImage_out.png", System.Drawing.Imaging.ImageFormat.Png);