DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Rebecca has posted 1 posts at DZone. View Full User Profile

Spire.XLS for .NET supports converting Excel worksheets to images.

06.06.2013
| 2097 views |
  • submit to reddit
Steps of converting Excel worksheets to Image
    Create a new workbook
    Load information from excel file and transfer into workbook
    Save workbook as any image file format at your will

Excel to Image

 Download Spire.XLS for .NET (or Spire.Office) with .NET Framework 2.0 (or above) together. In your application add Spire.XLS reference. The following code snippet shows how to convert an Excel worksheet to an image in C#, VB.NET.

 
C# Convert Excel to Image:
[C#]
01	using Spire.Xls;
02	namespace Xls2Image
03	 
04	{
05	    class Program
06	    {
07	        static void Main(string[] args)
08	        {
09	            Workbook workbook = new Workbook();
10	            workbook.LoadFromFile(@"..\..\test.xls");
11	            Worksheet sheet = workbook.Worksheets[0];
12	            sheet.SaveToImage("sample.jpg");
13	        }
14	    }
15	}
VB.NET Convert Excel to Image:
[Visual Basic]
01	Imports Spire.Xls
02	Namespace Xls2Image
03	       Friend Class Program
04	              Shared Sub Main(ByVal args() As String)
05	                     Dim workbook As New Workbook()
06	                     workbook.LoadFromFile("..\..\test.xls")
07	                     Dim sheet As Worksheet = workbook.Worksheets(0)
08	                     sheet.SaveToImage("sample.jpg")
09	              End Sub
10	       End Class
11	End Namespace
12	        

 

 Making a Microsoft Excel worksheet to an image file can be quite useful when you might need to use an image of a worksheet in an application or web page. This can be the most effective solution for developers to convert worksheet to image as this solution converts Excel spreadsheets-including all text, formatting and diagrams-to graphic files.

Steps of converting Excel worksheets to Image
  Step1.Create a new workbook
  Load information from excel file and transfer into workbook
  Save workbook as any image file format at your will

 Step2.Excel to Image

 Download Spire.XLS for .NET (or Spire.Office) with .NET Framework 2.0 (or above) together. In your application add Spire.XLS reference. The following code snippet shows how to convert an Excel worksheet to an image in C#, VB.NET.

C# Convert Excel to Image:

[C#]
01using Spire.Xls;
02namespace Xls2Image
03
04{
05class Program
06{
07static void Main(string[] args)
08{
09Workbook workbook = new Workbook();
10workbook.LoadFromFile(@"..\..\test.xls");
11Worksheet sheet = workbook.Worksheets[0];
12sheet.SaveToImage("sample.jpg");
13}
14}
15}

VB.NET Convert Excel to Image:

[Visual Basic]
01Imports Spire.Xls
02Namespace Xls2Image
03Friend Class Program
04Shared Sub Main(ByVal args() As String)
05Dim workbook As New Workbook()
06workbook.LoadFromFile("..\..\test.xls")
07Dim sheet As Worksheet = workbook.Worksheets(0)
08sheet.SaveToImage("sample.jpg")
09End Sub
10End Class
11End Namespace
12



 Spire.XLS for .NET supports converting Excel worksheets to images. To use this feature, you need to invocate the method-public void SaveToImage(string fileName) in your program or project. You can convert a worksheet to image file(s) with different attributes or options and you can save the image file to disk. Most image formats are supported, such as BMP, PNG, GIF, JPG, JPEG, TIFF, and etc.

 Spire.XLS for .NET is produced by E-iceblue.E-iceblue Co., Ltd. ,which is a vendor of .NET, Silverlight and WPF development components. The goal of e-iceblue is always to offer high-quality components for reading and writing different formats of office files. Our components have been widely-used by most of the Fortune 500 corporations. The key developers of e-iceblue have over 10 years of combined experience developing high-performance, high-quality .NET, Silverlight and WPF component technology. Everyday, e-iceblue products help a large number of developers from large/small companies in more than sixty countries to easier, better, faster and to be more productive develop and deliver reliable applications to their customers.

More about the function of Spire .XLS, please visit:
http://www.e-iceblue.com/Introduce/excel-for-net-introduce.html



    Tags: