Reputation: 2215
Hey guys, i dont have a clear definition of what my client wants but i figured i could get a dialogue going.
so my client wants to take some html from a page and convert it to and xls form. all the data and content is from their own website/portal and they just need the reports converted to xls for accounting or something.
Oh yeah, id like to keep this in .NET C# please...
has anybody done this? What options are there?
Thanks guys!
Upvotes: 0
Views: 4459
Reputation: 101
You can do this with Libreoffice converting the html to xlsx. You can even preserve date formats. I did long ago write this up ... I just re-posted it at http://wjmceachran.com/2020/04/create-excel-files-from-legacy-system-with-libreoffice/
Upvotes: 0
Reputation: 470
My company's developed an HTML to XLS API called DocRaptor that can do this. DocRaptor is a Ruby on Rails project, but we use HTTP POST requests to generate documents. We've got a C# example on our documentation page, which you can see here:
And here's a link to our homepage:
Upvotes: 1
Reputation: 39695
The easiest approach is to to just output a html table, and set the mime-type to application/vnd.ms-excel as @Rubens Farias said. If you have access to the existing application it's easy to extend, if not you must grab the html and parse it.
Excel can parse html tables without problems, even with formatting:
<html>
<body>
<table border="1">
<tr>
<td style="background-color: red">Content in cell</td>
<td>Cell 2</td>
</tr>
</table>
</body>
</html>
Upvotes: 2
Reputation: 57936
You can grab that external page by using XHR, parse it's HTML and to return your data with content-type = "application/vnd.ms-excel"
Upvotes: 2
Reputation: 180004
You can highlight any table and copy/paste it into Excel and Excel should handle the conversion nicely.
You can also provide .CSV versions of your reports.
Upvotes: 0