|
我想要用JAVA读取MICROSOFT WORD 然后试了很多CODING但是我还是做不到, 希望会的人可以教我.谢谢! |
|
|
|
|
|
|
|
楼主 |
发表于 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 找找吧.. |
|
|
|
|
|
|
| |
本周最热论坛帖子
|