如题,例子就可以了!谢谢各位了!

解决方案 »

  1.   

    有个日本人做的开源包叫JCOM是一个java与COM的桥以前用过操作EXCEL打印的COM接口package test;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;
    import exception.ReportPrintException;public class TestCom {
        private String filename;    public TestCom() {    }    public void setPrintFilename(String file) {
            filename = file;
        }    public boolean print() throws ReportPrintException {
            boolean success = false;
            if (filename != null) {
                ReleaseManager rm = new ReleaseManager();
                try {
                    ExcelApplication excel = new ExcelApplication(rm);                ExcelWorkbooks xlBooks = excel.Workbooks();
                    ExcelWorkbook xlBook = xlBooks.Open(filename);
                    ExcelWorksheet xlSheet = excel.ActiveSheet();
                    excel.Visible(true);
                    xlSheet.method("print",null);
                    xlBook.Close(false, null, false);
                    excel.Quit();                success = true;
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new ReportPrintException(e.getMessage());
                } finally {
                    rm.release();
                }
            }
            return success;
        }
        
        public static void main(String[] args){
            TestCom com=new TestCom();
            com.setPrintFilename("C:\\aaa.xls");
            try {
                com.print();
            } catch (ReportPrintException e) {
                e.printStackTrace();
            }
        }
    }
      

  2.   

    现在已经纳入sun了,想问下,下命令给com的时候,收到的数据用什么接收,怎么接收?