Work with images in Excel spreadsheet in .NET

Elerium Excel .NET component, new release 2.0 has been introduced by Elerium Software.
 
June 6, 2013 - PRLog -- In order to create a well-formed report in MS Excel is not always enough data alone. A simple table with the text can be informative, but not very presentable for clients. Often, reports may contain the images. For example, a good practice is to add a company logo, along with the title of the report. Besides this, the price list will be much more informative if it contains the thumbnails of goods.

If it is needed to create a small report, then the best choice is the MS Excel. But what if it is necessary to generate large reports regularly with a huge amount of data on the server without installed MS Excel? Elerium Software offers Excel .NET component as a great solution for .NET developers.

Elerium Excel .NET component, new release 2.0 has been introduced by Elerium Software. It has several important changes:

- New algorithm of reading OLE2 Stream in Excel file.
- New algorithm of parsing Excel Stream.
- New function restructuring.
- Fixed Border properties.

How to work with images in Excel spreadsheet using Elerium Excel .NET component? This is very easy. First of all, a developer must install component to the project:
1. Add Elerium Excel .Net component to the solution. Simply put Excel.dll into /bin folder of the project.
2. Initialize the Docs.Excel instance.

When the component is connected to the project a developer can create a new Excel document and add an image to the spreadsheet in a certain position:

C# code:

using System;
using System.Collections.Generic;
using System.Text;
using Docs.Excel;

namespace WriteImages
{
class Program
{
static void Main(string[] args)
{
//Create a new workbook.
ExcelWorkbook Wbook = new ExcelWorkbook();

//Add new worksheet to workbook.
Wbook.Worksheets.Add("Sheet1");

//Insert an image.
Wbook.Worksheets[0].Pictures.Add(@"c:/Image.jpg");

//Set position of picture.
Wbook.Worksheets[0].Pictures[0].SetPosition(1, 1);

//Write .xlsx file.
Wbook.WriteXLSX(@"c:/WriteImages.xlsx");

}
}
}

VB.NET code:

Module Module1

Sub Main()
'Create a new workbook.
Dim Wbook = New ExcelWorkbook()

'Add new worksheet to workbook.
Wbook.Worksheets.Add("Sheet1")

'Insert an image.
Wbook.Worksheets(0).Pictures.Add("c:/Image.jpg")

'Set position of picture.
Wbook.Worksheets(0).Pictures(0).SetPosition(1, 1)

'Write .xlsx file.
Wbook.WriteXLSX("c:/WriteImages.xlsx")

End Sub

End Module

Also a developer can use Elerium Excel .NET component to extract images from existing Excel spreadsheet:

C# code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Docs.Excel;

namespace ReadImage
{
class Program
{
static void Main(string[] args)
{
ExcelWorkbook Wbook = ExcelWorkbook.ReadXLSX(@"c:/ReadImage.xlsx");

Wbook.Worksheets[0].Pictures[0].Image.Save("Logo.jpg");
}
}
}
VB.NET code:
Module Module1

Sub Main()
Dim Wbook = ExcelWorkbook.ReadXLSX("c:/ReadImage.xlsx")

Wbook.Worksheets(0).Pictures(0).Image.Save("Logo.jpg")

End Sub

End Module

About Elerium Software

Elerium Software develops professional solutions for use in .NET projects (C#, VB.NET, ASP.NET) that aimed to read/write/convert different office/web documents and formats. Elerium Software components are based on the unique design and fast algorithms that allow being independent from the third-party applications and libraries.

For more information about the component please visit the product page:
http://www.eleriumsoft.com/Excel_NET/ExcelNET/Default.aspx
End
Source: » Follow
Email:***@eleriumsoft.com Email Verified
Tags:Read, Write, Excel, Net, Asp Net
Industry:Computers, Software
Location:luzern - Switzerland
Account Email Address Verified     Account Phone Number Verified     Disclaimer     Report Abuse
Elerium Software News
Trending
Most Viewed
Daily News



Like PRLog?
9K2K1K
Click to Share