C#: Online Guide
How To: excel SDK
Convert Excel to Png, Gif, Bitmap ... Images
Convert Excel to Png, Gif, Bitmap … images
  |  
Home ›› XDoc.Excel ›› C# Excel: Convert Excel to Png, Gif, Bitmap ... Images

C# Excel - Render Excel to Other Images


Online C# Tutorial for How to Convert Excel to Raster Images, .NET Graphics, and REImage




Excel to Multiple Image Forms Conversion



RasterEdge.com provides C# developers with mature Excel document processing and rendering library SDK. Our XDoc.Excel allows C# developers to perform high performance conversions from Excel document to multiple image forms. Besides raster image Jpeg, images forms like Png, Bmp, Gif, .NET Graphics, and REImage (an intermediate class) are also supported. In the following parts, we provide some examples for these Excel conversions.


Related .net document control helps:
asp.net webforms pdf editor control: ASP.NET WebForms PDF Editor: create, view, edit, annotate, redact PDF file in ASP.NET WebForms application
asp.net edit pdf text control: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net create pdf control: ASP.NET Create PDF Document Control: create, convert PDF file from Word, Excel, Tiff file formats in C# ASP.NET
asp.net pdf editor control: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
asp.net azure pdf editor control: ASP.NET Azure PDF Editor Control: view, edit, annotate, redact PDF files online
asp.net azure file viewer: ASP.NET Azure Document Viewer: view, annotate files online using ASP.NET Cloud Service
asp.net iis file viewer: C# HTML5 Viewer: Deployment on IIS




C# DLLs: Convert Excel to Images



Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Office.Inner.Office03.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.XDoc.Excel.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


Using namespaces:


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.Excel;




C# Sample Code for Excel to Png



You can use this sample code to convert Excel file to Png image.




// Load a Excel file.
String inputFilePath = Program.RootPath + "\\" + "1.xlsx";
XLSXDocument doc = new XLSXDocument(inputFilePath);

// Get the first page of Excel file.
XLSXPage page = (XLSXPage)doc.GetPage(0);

// Convert the first Excel page to a PNG file.
page.ConvertToImage(ImageType.PNG, Program.RootPath + "Output.png");





C# Sample Code for Excel to Bmp



Or use this piece of C# code to implement Excel to Bmp conversion.




// Load a Excel file.
String inputFilePath = Program.RootPath + "\\" + "1.xlsx";
XLSXDocument doc = new XLSXDocument(inputFilePath);

// Get the first page of Excel file.
XLSXPage page = (XLSXPage)doc.GetPage(0);

// Convert the first Excel page to a BMP file.
page.ConvertToImage(ImageType.BMP, Program.RootPath + "\\Output.bmp");





C# Sample Code for Excel to Gif



You can also directly change Excel to Gif image file in C# program.




// Load a Excel file.
String inputFilePath = Program.RootPath + "\\" + "1.xlsx";
XLSXDocument doc = new XLSXDocument(inputFilePath);

// Get the first page of Excel file.
XLSXPage page = (XLSXPage)doc.GetPage(0);

// Convert the first Excel page to a GIF file.
page.ConvertToImage(ImageType.GIF, Program.RootPath + "\\Output.gif");





C# Sample Code for Excel to REImage



Using namespace(Extra):


  using RasterEdge.Imaging.Raster.Core;


Instead, you may render Excel to REImage (an intermediate class) and then do further manipulations.




// Load a Excel file.
String inputFilePath = Program.RootPath + "\\" + "1.xlsx";
XLSXDocument doc = new XLSXDocument(inputFilePath);

// Get the first page of Excel.
XLSXPage page = (XLSXPage)doc.GetPage(0);

// Convert the first page to a REImage object.
REImage image = (REImage)page.ConvertToImage();

// Do something ...





C# Sample Code for Excel to .NET Bitmap



Moreover, our SDK also allows you to render Excel to .NET Bitmap in C# programming.




// Load a Excel file.
String inputFilePath = Program.RootPath + "\\" + "1.xlsx";
XLSXDocument doc = new XLSXDocument(inputFilePath);

// Get the first page of Excel.
XLSXPage page = (XLSXPage)doc.GetPage(0);

// Render the page to a Bitmap with default setting.
Bitmap bitmap1 = page.GetBitmap();
bitmap1.Save(inputFilePath + "_1.bmp");
//  ...

// Enlarge the page with factor 2.
float zoomRatio = 2.0F;
Bitmap bitmap2 = page.GetBitmap(zoomRatio);
bitmap2.Save(inputFilePath + "_2.bmp");
//  ...

// Render the page with a resolution of 300 dpi.
int targetResolution = 300;
Bitmap bitmap3 = page.GetBitmap(targetResolution);
bitmap3.Save(inputFilePath + "_3.bmp");
//  ...