提取网页并将其保存到excel shhet的Java代码 [英] java code to extract webpage and save it to excel shhet

查看:53
本文介绍了提取网页并将其保存到excel shhet的Java代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问问是否有人可以帮助我提取网页的Java代码并将数据保存到Excel工作表中?

并提取pdf文件,并将其保存到excel表中

谢谢,我在等待帮助.

i would like to ask if anyone can help me with the java code that extract webpage and save the data to excel sheet

and extract pdf file and save it to excel sheet also

thank you and i am waiting help

推荐答案

这不是一个简单的问题,请参见
This is not a simple issue, see here[^] for some guides on how to read and interpret data from a web page. To read from a PDF file and write to Excel you will probably need some third party libraries; try Google for both subjects to see what is available.


我不明白. Java代码? JSP?

另外,您还应指定要提取到.xls的内容.一件事是将网页转换"为PDF,对于excel,您需要指定保存内容和保存位置.

无论如何,因为我不确定您是否正在使用JSP(或完全使用Web开发语言.),您可以使用Javascript
完成它
I dont understand. Java code? JSP?

Also you should specify what exactly do you want to extract to .xls. One thing is to "convert" the webpage to PDF, for excel you need to specify what and where to save.

Anyway, because I''m not sure you''re using JSP (or web development language at all..) you could accomplish it using Javascript

<script language=javascript>
function exportToExcel()
{
var oExcel = new ActiveXObject("Excel.Application");
var oBook = oExcel.Workbooks.Add;
var oSheet = oBook.Worksheets(1);
for (var y=0;y<detailsTable.rows.length;y++)

// detailsTable is the table where the content to be exported is

{

for (var x=0;x<detailsTable.rows(y).cells.length;x++)

{

oSheet.Cells(y+1,x+1) =
detailsTable.rows(y).cells(x).innerText;

}

}

oExcel.Visible = true;

oExcel.UserControl = true;

}

</script>
<button onclick="exportToExcel();">Export to Excel File</button>

<table name="detailsTable">
<tr>
<td> hello
</td>
</tr>
</table>


这篇关于提取网页并将其保存到excel shhet的Java代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆