このタスクは2つのステップに分割する必要があり、異なる問題を解決するため、JsoupとPOIの両方が必要になります。
- グラブのウェブページと解析(Jsoup)は
- 書き込みは、Excelスプレッドシートに結果を解析された(POI)
1)あなたは、Webページを取得し、解析するJsoupを使用することができ、Jsoup Cookbookがありあなたがこれをやることができる多くの簡単な例。あなたは、例えば可能性:
Document doc = Jsoup.connect("http://example.com/").get(); // Grab page
Element table = doc.getElementById("my-table"); // Get table with id "my-table"
セレクタを使用することによって、あなたはあなたが必要とするデータを読むことができたとPOJOにそれを書くか、どこでも、あなたが本当に好き。
2)必要なデータがあれば、POIを使用してExcelスプレッドシートを作成することができます。
ビジーデベロッパーガイドには、how to write to an excel sheetと、hyperlinksの作成方法が示されています。
ハイパーリンクを作成するための要旨は次のとおりです。
Workbook wb = new XSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("Test sheet");
Cell cell = sheet.createRow(0).createCell((short)0);
cell.setCellValue("URL Link"); // Text that will be shown, e.g. AL2015
Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
link.setAddress("http://poi.apache.org/"); // Set actual hyperlink URL
cell.setHyperlink(link); // Add hyperlink to cell