cxh1299543968
KaisonChen
2016-06-16 06:08

jacob Excel转PDF问题,列显示不全

20

利用jacob将Excel转换为PDF时,Excel中的列在PDF中显示不全如下图,加班费合计右面应该还有列,但是没有显示。另外,各列的数据数据显示不全,如身份证号图片说明

下面是我的代码

    public boolean excelTopdf(String inputFile, String pdfFile){

         ComThread.InitSTA();
         ActiveXComponent app = new ActiveXComponent("Excel.Application");
         app.setProperty("Visible", new Variant(false));
         Object excels = app.getProperty("Workbooks").toDispatch();
         Object excel = Dispatch.invoke(
                 (Dispatch) excels,
                 "Open",
                 Dispatch.Method,
                 new Object[] { inputFile, new Variant(false),
                         new Variant(true) }, new int[9]).toDispatch();

         Dispatch currentSheet = Dispatch.get((Dispatch) excel,
                 "ActiveSheet").toDispatch();
         Dispatch pageSetup = Dispatch.get(currentSheet, "PageSetup")
                 .toDispatch();
         Dispatch.put(pageSetup, "Orientation", new Variant(2));

         Dispatch.call(currentSheet, "SaveAs", pdfFile,
                     new Variant(57));
             if (app != null) {
                 app.invoke("Quit", new Variant[] {});
                 app = null;
             }
             ComThread.Release();

        return true;

    }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答