Export HTML to Excel – component for .NET
03/09/2013

Elerium Software has introduced a new version of Elerium HTML to Excel .NET component.

Online PR News – 09-March-2013 – Luzern – Today a lot of data in internet is stored in HTML format. This is very handy when it’s required to display a report or presentation. But the processing of such data is extremely difficult. In most cases the data that require analyze is presented in tabular form, so the best solution for their processing is to convert document into a Microsoft Excel format. Microsoft Excel is the industry standard for spreadsheet software and it gives the ability to analyze large amount of data. Microsoft Excel is a very powerful and versatile tool and can be used for many different purposes: report, calendar, schedule, financial tools, pricelist, budget and etc.

If a small amount of data, it can be moved in the Excel spreadsheet manually. But what if it is needed to convert a lot of HTML documents inside C#/VB.NET/ASP.NET project? The best and the fastest way is a using of different .Net libraries. One of these libraries is introduced by Elerium Software. Elerium HTML to Excel .NET component offers full support for HTML formatting, including tables, CSS, graphics, tables, borders and is able to convert HTML to Excel files (XLS, XLSX, CSV).

First of all, a developer must install HTML to Excel .NET component to the project:
1. Download the latest version of the component from this link: http://www.eleriumsoft.com/Excel_NET/HTML2Excel/Default.aspx
2. Extract the downloaded archive and put the Excel.dll component into /bin folder of the project.
3. Add the component to the “using” section:
using Docs.Html;
using Docs.Converting;
using Docs.Spreadsheet;

When the component is connected to the project, a developer can convert HTML to Excel spreadsheet. This code will display how simple it is to convert HTML file to Excel workbook with formatting:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Docs.Html;
using Docs.Converting;
using Docs.Spreadsheet;
namespace PreserveFormatting
{
class Program
{
static void Main(string[] args)
{
// Read the specified html file.
HtmlDoc html = HtmlDoc.ReadHTML(@"..\..\..\Capitals.html");
// Convert Html table to Excel with formatting preservation
HtmlToExcel htmlexcel = new HtmlToExcel();
htmlexcel.PreserveFormatting = true;
ExcelWorkbook excel = htmlexcel.Convert(html);
//Add text and save Excel file as XLSX format.
excel.WriteXLSX(@"..\..\..\Export_Html.xlsx");
//Open specified file in MS Excel.
System.Diagnostics.Process.Start(@"..\..\..\Export_Html.xlsx");
}
}
}

Also the component allows editing the resulting Excel file and placing the resulting table to a certain place on the page:

using System;
using System.Collections.Generic;
using System.Text;
using Docs.Html;
using Docs.Converting;
using Docs.Spreadsheet;
namespace SetPositionTable
{
class Program
{
static void Main(string[] args)
{
// Read the specified html file.
HtmlDoc html = HtmlDoc.ReadHTML(@"..\..\..\HorseRider.html");
// Set position Row 2, Column 1
HtmlToExcel htmlexcel = new HtmlToExcel();
htmlexcel.RowStart = 2;
htmlexcel.ColumnStart = 1;
// Convert Html table to Excel starting from cell "B3"
ExcelWorkbook excel = htmlexcel.Convert(html);
//Add text and save Excel file as XLSX format.
excel.Worksheets[0].Cells["B2"].Value = "HTML to Excel .NET converter";
excel.Worksheets[0].Cells["B2"].Style.Font.Bold = true;
excel.WriteXLSX(@"..\..\..\ExcelConverter.xlsx");
//Open specified file in MS Excel.
System.Diagnostics.Process.Start(@"..\..\..\ExcelConverter.xlsx");
}
}
}

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/HTML2Excel/Default.aspx

If you have any questions or concerns about component, let us know:
http://eleriumsoft.com/Company/Contact.aspx