佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 758|回复: 3

java 问题

[复制链接]
发表于 24-2-2006 04:15 PM | 显示全部楼层 |阅读模式
我想要用JAVA读取MICROSOFT WORD 然后试了很多CODING但是我还是做不到, 希望会的人可以教我.谢谢!
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 24-2-2006 04:18 PM | 显示全部楼层
这是在下的CODING
        public String printDoc(){
                        try{
                       
        String realPath="";
        InputStream is = new BufferedInputStream(new FileInputStream("C:/Documents and Settings/All User/Desktop/Alumni.doc"));
        PrintRequestAttributeSet pras1= new HashPrintRequestAttributeSet();
        DocFlavor flavor1= DocFlavor.INPUT_STREAM.AUTOSENSE;
        PrintService defaultService= PrintServiceLookup.lookupDefaultPrintService();
         DocPrintJob job = defaultService.createPrintJob();
                DocAttributeSet das = new HashDocAttributeSet();

Doc doc1 = new SimpleDoc(is, flavor1, das);

job.print(doc1, pras1);

Thread.sleep(10000);

System.exit(0);

        }catch (Exception ex){
                        }
                        return "";
}

if(e.getSource()==print){
                 
                PrinterJob printJob = PrinterJob.getPrinterJob();
               
                       
/* Set up Book */
        PageFormat landscape = printJob.defaultPage();
        PageFormat portrait = printJob.defaultPage();
        landscape.setOrientation(PageFormat.LANDSCAPE);
        landscape.setOrientation(PageFormat.PORTRAIT);

//Page dialog
        PageFormat pf = printJob.pageDialog(printJob.defaultPage());
        printDoc();

//Print dialog
        if(printJob.printDialog()){
          try { printJob.print(); } catch (Exception PrintException) { }
        }

}
回复

使用道具 举报

发表于 26-2-2006 01:40 PM | 显示全部楼层
Apache Jakarta 有提供一个 API 叫 POI 。我试过用来写及读 Excel file, 都没问题,我想应该也能够用在 Word file,去Apache Jakarta 网站看看吧。
回复

使用道具 举报

发表于 26-2-2006 02:10 PM | 显示全部楼层
JAVA 没有读EXCEL的CLASS/OBJ..要另找..
我上次有找过,但名字忘了..
自己用google 找找吧..
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 21-9-2024 10:52 PM , Processed in 0.133189 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表