java实现打印(C/S模式的),有没有例子?目前我用的是JCOM实现打印,但是卸载office之后报“jp.ne.so_net.ga2.no_ji.jcom.JComException:createInstance()failed HRESULT=0x800401F3L”,怎样让它在不安装office的情况下也能打印(即支持WPS)?源代码如下:package com.psbc.print;
import jp.ne.so_net.ga2.no_ji.jcom.ReleaseManager;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelApplication;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorkbook;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorkbooks;
import jp.ne.so_net.ga2.no_ji.jcom.excel8.ExcelWorksheet;
public class JCOM {
public boolean print(String fname) {
ReleaseManager rm = new ReleaseManager();
try {
ExcelApplication excel = new ExcelApplication(rm);
ExcelWorkbooks xlBooks = excel.Workbooks();
ExcelWorkbook xlBook = xlBooks.Open(fname);
ExcelWorksheet xlSheet = excel.ActiveSheet();
xlSheet.PrintOut();
xlBook.Close(false, null, false);
excel.Quit();
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
rm.release();
}
return true;
}
public static void main(String[] args) {
JCOM test = new JCOM();
try {
test.print("D://test.xls");
} catch (Exception e) {
e.printStackTrace();
}
}
}