利用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;
}