62,635
社区成员




ActiveXComponent xl = null;
//ComThread.InitSTA();
try{
xl = new ActiveXComponent("Excel.Application");
Dispatch.put(xl, "Visible", new Variant(true));
Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();
Dispatch.get(workbooks, "password");
//Variant asp = Dispatch.call(as, "Protect","password",new Variant(true),new Variant(true),new Variant(true));
// Dispatch cell = Dispatch.invoke(workbooks, "password", Dispatch.Get,new Object[] {0},new int[1]).toDispatch();
// String value = Dispatch.get(cell,"Value").toString();
Dispatch workbook = Dispatch.invoke((Dispatch) workbooks, "Open", Dispatch.Method, new Object[]
{xlsfile, new Variant(false), new Variant(true) }, new int[1]).toDispatch(); // readonly
workbook.safeRelease();
Dispatch.invoke(workbook, "SaveAs", Dispatch.Method, new Object[] { htmlfile, new Variant(44) }, new int[1]);
Dispatch.call(workbook, "Close", new Variant(false));
} catch (Exception e) {
Logger.getLogger(FileUtil.class).error(e);
} finally {
xl.invoke("Quit", new Variant[] {});
xl = null;
//ComThread.Release();
}
ActiveXComponent xl = null;
//ComThread.InitSTA();
try{
xl = new ActiveXComponent("Excel.Application");
Dispatch.put(xl, "Visible", new Variant(true));
Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();
Dispatch workbook = Dispatch.invoke((Dispatch) workbooks, "Open", Dispatch.Method, new Object[]
{xlsfile, new Variant(false), new Variant(true) }, new int[1]).toDispatch(); // 是否以只?方式打?
Dispatch.invoke(workbook, "SaveAs", Dispatch.Method, new Object[] { htmlfile, new Variant(44) }, new int[1]);
Dispatch.call(workbook, "Close", new Variant(false));
} catch (Exception e) {
Logger.getLogger(FileUtil.class).error(e);
} finally {
xl.invoke("Quit", new Variant[] {});
xl = null;
//ComThread.Release();
}