将html页面转换为excel [英] Convert html page to excel
问题描述
大家好,
我需要使用c#将html页面转换为 excel格式化。请帮我解决这个问题。或者建议我使用任何第三方工具将html转换为excel(带格式)。
先谢谢,
Arunachalam M.
Hi All,
I need to convert html page to excel with formatting using c#. Please help me to work on this. Or suggest me any third party tools to convert html to excel (with formatting).
Thanks in Advance,
Arunachalam M.
推荐答案
你可以从 http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/ASPNET/export-table-to-excel-with-grid-lines [ ^ ]。
生成Excel(XML电子表格) )在C#中[ ^ ]可以也给你一些想法。
Readi使用JET HTML导入可安装的ISAM驱动程序 HTML表[ ^ ]也可能对你有所帮助。
You could start with http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/ASPNET/export-table-to-excel-with-grid-lines[^].
Generating Excel (XML Spreadsheet) in C#[^] could give you some idea as well.
Reading HTML Tables with the JET HTML Import Installable ISAM Driver[^] might help you too.
至于html要格式化问题,你可以看到下面的代码:
As for html to excel with formatting issue, you can see below code:
Response.Clear();
Response.Buffer = true;
Response.AppendHeader("Content-Disposition","attachment;filename="+DateTime.
Now.ToString("yyyyMMdd")+".xls");
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = ""application/ms-excel";;
this.EnableViewState = false;
默认设置为text / HTML的ContentType属性可以帮助我们很多。超文本将导出到客户端。如果我们将其更改为ms-excel,它将以Excel格式导出并且您的浏览器会提醒您下载并存储它。ContentType的属性包括图像/ JPEG,文本/ HTML,图像/ GIF和vnd.ms-excel / msword。
The "ContentType" property which the default set is text/HTML can help us a lot. And hypertext will be exported to client. If we change it to ms-excel, it will be exported as Excel format and your browser will remind you to download and store it. The property of "ContentType" includes image/JPEG, text/HTML, image/GIF and vnd.ms-excel/msword.
什么格式?Excel将打开一个CSV,所以只需将您的数据以CSV格式发出,即可创建与Excel兼容的下载。
What formatting ? Excel will open a CSV, so just emit your data as a CSV to create an Excel compatible download.
这篇关于将html页面转换为excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!