如何将一段html导入到Excel中
需求:
1.我需要将表格导出为excel文件。
2.我首先将其呈现在html页面中。我有一个导出为 html 的按钮。
我的意见:
1.我从页面获取html:
document.getElementById('content').value = document.getElementById('containerId').innerHTML;
form1.submit();
2.我从服务器获取它,response.ContentType =“application/vnd.ms-excel;” // 需要客户端已安装Microsoft Excel。
3.我得到了正确的Excel文件“XXXX.xls”。
4.但是但是但是,当我打开它时,它警告我,就像
"it's not the right format of Excel, are you confirm to open it?"
我很遗憾看到它一样。
所以我想将 HTML 部分导入到 Excel 文件中,然后将正确的 Excel 文件响应给 USER-AGENT。
我在我的项目中使用了Aspose.Cells库,我不知道如何使用它来完成任务,或者有其他解决方案来解决它吗?
Requirement:
1.I need to export a table as a excel file.
2.I render it in a html page at first. I have a button to export to html.
My opinion:
1.I get the html from page:
document.getElementById('content').value = document.getElementById('containerId').innerHTML;
form1.submit();
2.I get it from server, response.ContentType = "application/vnd.ms-excel;" // it need the client has installed Microsoft Excel.
3.I got the right Excel file "XXXX.xls".
4.BUT BUT BUT, when I open it, it's alert a waring tell me like
"it's not the right format of Excel, are you confirm to open it?"
I'm feel sorry to see it.
So I want to import the HTML section into a Excel file, then response the right Excel file to USER-AGENT.
I have use the Aspose.Cells library in my project, I don't know how to use it to finish the task, Or is any other solution to solve it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要使用 Aspose.Cells for .NET 将 html 标签/部分解析为 Excel 电子表格,您可以使用 Cell.HtmlString 属性在单元格中设置所需的 html 代码段,它将在生成的 Excel 文件中进行相应的解析。请注意,目前并非所有 html 标签都受支持。
Aspose.Cells for .NET还支持将Excel文件直接转换为Html文件,请参阅支持转换的文件格式的文档,可能会对您有所帮助:
http://www.aspose .com/documentation/.net-components/aspose.cells-for-.net/opening-files.html
http://www.aspose .com/documentation/.net-components/aspose.cells-for-.net/ saving-files.html
如果您仍然遇到一些问题/困惑,请向我们提供使用 Aspose.Cells API 的示例代码的详细信息,我们可以帮助您。
If you need to parse html tags/portion to Excel spreadsheet using Aspose.Cells for .NET, you may use Cell.HtmlString attribute to set your desired html code segment in a cell, it will be parsed accordingly in the generated Excel file. Mind you, not all the html tags are supported at the moment.
Aspose.Cells for .NET also supports to convert an Excel file to Html file directly, see the documents on which file formats are supported for conversion, it may help you for your reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/opening-files.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/saving-files.html
If you still have some issue/confusion, kindly give us details with your sample code using Aspose.Cells API, we can help you.