This project has moved. For the latest updates, please go here.

Export data(HTML FORMAT) in a web application to Excel 2007

Mar 5, 2012 at 8:43 AM

Hi all,

EPPlus is working perfectly when we transform Datatable to excel sheet using 'LoadFromDataTable' method. But here i have a scenario where i need to transform a string which contains HTML data to excel sheet. I have tried with 'LoadFromText', but no luck.
Please find my string variable code below:
string s = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC- html40'>";       
s += "<meta http-equiv=Content-Type content='text/html; charset=us-ascii'>
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content='Microsoft Excel 9'>
<link rel=File-List href='./mmmm_files/filelist.xml'>
<link rel=Edit-Time-Data href='./mmmm_files/editdata.mso'>
<link rel=OLE-Object-Data href='./mmmm_files/oledata.mso'>";       
s += "<title>Html Table</title>";
s += "<body><table border=1>";
s += "<tr><td>";
-----------(and so on)----------------
s += "</table>";       
s += "</body></html>";
With the help of the code below i was able to transform HTML content in string 's' to .xls
Response.Write(s);
Response.ContentType = "application/msexcel";       
Response.AppendHeader("content-disposition", "attachment;filename=OfferDetails.xls");
Response.End();
But how can i achieve this in our EPPlus project.
 
Hope someone can help me! Thanks all for your effort!
 
Your consideration is greatly appreciated..
 
Regards,
Camirine
 

 

Developer
Mar 6, 2012 at 6:45 PM

Hi,

Jan is on vacation, but I'm quite sure that EPPlus cannot parse HTML. That is a feature of the Excel application.

If you are creating the html string in your code, couldn't you rather just insert the data in the cells of a worksheet via EPPlus?

/Mats

Mar 9, 2012 at 8:55 AM

Hi swmal,

Thanks for ur reply.

I was able to transform Datatable to excel sheet using 'LoadFromDataTable' method. But i need to perform some calculations on the data available.

Can you please suggest me how can we perform calculations (Round, Sum) on Excel cells using EPPlus software.

Thanks in advance for your effort!
 
Your consideration is greatly appreciated..
 
Regards,
Camirine