将HTML转换为Excel的最佳方式是什么? [英] What is the best way to convert HTML into Excel
问题描述
是否有任何可用于实现此目的的开源API。你能让我知道什么是可能的选择。
可以通过单独使用javascript来完成。
HTML表比较容易。您可以下载页面,解析HTML(有各种HTML解析库可用),提取表格并将其转换为CSV(Excel可以加载),或直接创建Excel文件,例如。使用Java POI,如上所述。
Flash部分更难。有很多工具可用于捕获图像的Flash,您需要使用其中的一个。这可能很棘手,因为Flash可能是交互式的,所以您可能需要远程控制Flash部件,以便在捕获之前显示正确的图像。很难说没有更多的信息。
这就是说,屏幕抓取(这正是你正在做的)总是劳动密集型和脆弱性。您应该真正推出一个更好的界面来获取您的数据,从长远来看,它将节省很多麻烦。
I have an HTML page which has a flash chart(FusionCharts) and HTML table. I need to convert this whole thing into Excel. HTML table should be displayed in cells of excel sheet. Flash chart can be displayed as an image.
Is there any open source API that we could use for achieving this. Could you let me know what are the possible options.
Can this be done by using javascript alone.
The HTML table is relatively easy. You can download the page, parse the HTML (there are various HTML parsing libraries available), extract the table and convert it into CSV (which Excel can load), or directly create an Excel file, e.g. using Java POI, as suggested above.
The Flash part is significantly harder. There are quite a few tools available to capture flash to an image, you'd need to use one of them. This can be tricky, as Flash might be interactive, so you'd possibly have to remote-control the Flash part so it shows the right image before capturing. Hard to tell without more info.
That said, screen-scraping (which is what you're doing) is always labour-intensive and fragile. You should really push for a better interface to get your data from, it will save loads of hassle in the long run.
这篇关于将HTML转换为Excel的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!