[英]Export HTML data table to Excel using POI
你能告訴我,在這種情況下我們如何處理我們有一個表格形式的純HTML數據,應該轉換成適當的excel表格。
這是我寫的源代碼,我得到一個異常 - >錯誤:無效的頭簽名; 讀取0x6D78206C6D74683C,預期為0xE11AB1A1E011CFD0 |#]
// Resulting byte stream from the DB
resultBytes = dokumentSession.getXlsZuAuftrag(ts);
if (resultBytes != null && resultBytes.length > 0) {
try {
InputStream fos = new ByteArrayInputStream(resultBytes);
HSSFWorkbook workbook = new HSSFWorkbook(fos);
workbook.createSheet("sheet1");
FileOutputStream fileOut = new FileOutputStream("ipa_loader.xls");
workbook.write(fileOut);
fileOut.close();
} catch (Exception e)
{// Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
請告知我對此的任何意見,任何幫助表示贊賞。
使用任何HTML解析器,您必須解析HTML內容,然后使用POI將內容寫入Excel。
鏈接:
POI示例
http://viralpatel.net/blogs/java-read-write-excel-file-apache-poi/
HTML解析器示例
http://jsoup.org/cookbook/extracting-data/example-list-links
您也可以輕松地將您的HTML代碼轉換為XLS。 在這里你可以找到例子http://wiki.sdn.sap.com/wiki/display/WDJava/Export+to+Excel+%28Without+third+party+APIs%29
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.