jcom打印 /Files/jlin/jcom224.rar
Setup
Extract "jcom222.zip". And copy jcom.jar and jcom.dll to the following directories
jcom.dll -> (java.home)/bin/
jcom.jar -> (java.home)/lib/ext/
make sure the JAVA_HOME evironmental variable has been set, ie.
(java.home) == java.lang.System.getProperty("java.home");
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.p
test.print("d:/test.xls");
} catch (Exception e) {
e.printStackTrace();
}
}
}
posted on 2009-04-15 16:36
fly 阅读(473)
评论(0) 编辑 收藏 所属分类:
java学习