Introduction
In Microsoft Excel, it is pretty easy to export an Excel range as an image with the following procedure.
- Select a section that you need to export as an image.
- Click Home>Copy>Copy as Picture, then the picture will be saved in the clipboard.
- Paste the copied picture to your Paint tool, then save the picture to the specified folder in the specified format.
However, in this article, I'll introduce you to how to convert section(s) to an image programmatically using the free Spire.XLS in C#. As a matter of fact, Spire.XLS has provided a Worksheet.SaveToImage(int firstRow, int firstColumn, int lastRow, int lastColumn) method for programmers to save a selected range of cells to an image easily. Now let's check the detailed procedure as in the following.
Step 1. Create a new Excel document and load the test file.
Step 2. Get the first sheet from the workbook
Step 3: Save a specific cell's range to an image via Worksheet.SaveToImage().
Test File

Example
// Initialize a new Workbook object
Workbook workbook = new Workbook();
// Open Template Excel file
workbook.LoadFromFile("Sample.xlsx");
// Get the first worksheet in Excel file
Worksheet sheet = workbook.Worksheets[0];
// Specify Cell Ranges and Save to certain Image formats
sheet.SaveToImage(1, 1, 6, 6).Save("Image1.png", ImageFormat.Png);
sheet.SaveToImage(7, 1, 13, 6).Save("Image2.jpeg", ImageFormat.Jpeg);
sheet.SaveToImage(14, 1, 19, 6).Save("Image3.bmp", ImageFormat.Bmp);
Output




Gowtham RajamanickamPosted Apr 25, 2015, 5:47 AM
good one
Manoj BhoirPosted Apr 25, 2015, 4:47 AM
Good one
NitinPosted Apr 25, 2015, 2:58 AM
Nice
Santhakumar MunuswamyPosted Apr 25, 2015, 12:19 AM
Thanks for nice one
Safayat ZisanPosted Apr 25, 2015, 12:11 AM
good work
Manoj KulkarniPosted Apr 24, 2015, 11:35 PM
Nice thank you for sharing
Karthik Muthu KaruppanPosted Apr 24, 2015, 5:49 PM
Good