Generating excel documents programmatically

后端 未结 8 1350
抹茶落季
抹茶落季 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: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!

提交回复
热议问题