导出HTML数据表使用POI Excel来 [英] Export HTML data table to Excel using POI

查看:306
本文介绍了导出HTML数据表使用POI Excel来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否请您让我知道,我们怎么能在这种情况下进行我们必须在表形式的纯HTML数据应被转化为正确的Excel工作表。

Can you please let me know, how we can proceed in this case we have a pure HTML data in the form of Tables which should be converted to proper excel sheet.

这是我写的源$ C ​​$ C,我得到一个异常 - >
错误:无效头签名;阅读0x6D78206C6D74683C,预计0xE11AB1A1E011CFD0 |#]

This is the source code which I have written, I get an exception --> Error: Invalid header signature; read 0x6D78206C6D74683C, expected 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());
        }
    }

请让我知道在这任何输入,任何帮助是AP preciated。

Please let me know any inputs on this, any help is appreciated.

推荐答案

使用,你必须解析HTML内容,然后使用POI内容写入Excel中的任何HTML解析器。

Using any HTML parser you have to parse your HTML content then write the content into Excel using POI.

链接:

POI示例

http://viralpatel.net/blogs/java - 读取,写入的Excel文件的Apache-POI /

HTML解析器示例

http://jsoup.org/cookbook/extracting-data/example-列表的链接

另外你也很容易地转换你的HTML code到XLS。
在这里你可以找到实例
http://wiki.sdn.sap.com/wiki/display/WDJava/Export+to+Excel+%28Without+third+party+APIs%29

Also you have easily convert your html code into XLS. Here you can find the example http://wiki.sdn.sap.com/wiki/display/WDJava/Export+to+Excel+%28Without+third+party+APIs%29

这篇关于导出HTML数据表使用POI Excel来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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