Generating excel documents programmatically

后端 未结 8 1291
抹茶落季
抹茶落季 2020-12-21 01:33

Has anyone used a Java based library for generating excel documents? Preferably support for 2003?

相关标签:
8条回答
  • 2020-12-21 01:39

    I'm currently working with Apache POI, ( http://poi.apache.org/index.html ) which is very comprehensive. The 2003 file format version is still in beta, but seems to work well enough. I'm not exercising it's power very much, just straightforward reads and writes of Excel, but it seems reliable.

    0 讨论(0)
  • 2020-12-21 01:41

    If you don't need fancy headings then just output CSV.

    0 讨论(0)
  • 2020-12-21 01:45

    You can generate an excel file with a VBS and then cal the script from java like this:

    String script = "your_VBS_Name.vbs"
    String cmd = "D:\\YourPath" + script;
    Runtime.getRuntime().exec(cmd);
    

    to create the script is really simple

    open notepad and follow the next example:

    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = True
    
    Set objWorkbook = objExcel.Workbooks.Add()
    objWorkbook.SaveAs("D:\yourExcel.xls")
    
    objExcel.Quit
    

    and then save it as your_VBS_Name.vbs

    Thats it!

    0 讨论(0)
  • 2020-12-21 01:49

    Whenever I have to do this I ask myself if one big html table would be enough.

    much of the time it is. You can simply write html tags and label it as a .xls file. Excel will open it correctly

    0 讨论(0)
  • 2020-12-21 01:50

    JExcelApi

    I've used it personally for a report that is currently in production. It's a fairly decent library with sufficient docs, and it's open source.

    It works very well, but has a few gotchas you should be aware of. None of them are deal breakers, just dictate how a few things should be done. Just be sure to read the FAQ. It will explain them and tell you how to avoid them.

    0 讨论(0)
  • 2020-12-21 01:51

    You can also try SmartXLS for java, it have more functions than poi and jexcelapi,and it is a commercial product.

    http://www.smartxls.com/indexj.htm

    0 讨论(0)
提交回复
热议问题