随笔 - 100  文章 - 50  trackbacks - 0
<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(3)

随笔分类

随笔档案

文章分类

文章档案

收藏夹

我收藏的一些文章!

搜索

  •  

最新评论

阅读排行榜

评论排行榜

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学习

只有注册用户登录后才能发表评论。


网站导航: