|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
最后我再次声明,我并没有说不看好java,实际上我对java很乐观的,毕竟她正在不断改进中,我相信她总有一天会和.net并驾齐驱的excel
try{getDBConnection();pstmt=conn.prepareStatement(strSql);ret=pstmt.executeQuery();FiletempFile=newFile(filename);try{WritableWorkbookworkbook=Workbook.createWorkbook(tempFile);WritableSheetsheet=workbook.createSheet("sheet1",0);Labell=null;jxl.write.Numbern=null;jxl.write.DateTimed=null;WritableFontheaderFont=newWritableFont(WritableFont.ARIAL,12,WritableFont.BOLD,false,UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLUE);WritableCellFormatheaderFormat=newWritableCellFormat(headerFont);
WritableFonttitleFont=newWritableFont(WritableFont.ARIAL,10,WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.RED);WritableCellFormattitleFormat=newWritableCellFormat(titleFont);
WritableFontdetFont=newWritableFont(WritableFont.ARIAL,10,WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK);WritableCellFormatdetFormat=newWritableCellFormat(detFont);
NumberFormatnf=newNumberFormat("0.00000");WritableCellFormatpriceFormat=newWritableCellFormat(detFont,nf);
DateFormatdf=newDateFormat("yyyy-MM-dd");WritableCellFormatdateFormat=newWritableCellFormat(detFont,df);
l=newLabel(2,0,"",headerFormat);sheet.addCell(l);intintTitle=title.length;for(inti=0;i<intTitle;i++){l=newLabel(i,2,title[i],titleFormat);sheet.addCell(l);}intk=0;while(ret.next()){k++;for(intj=1;j<intTitle;j++){l=newLabel(j-1,k+3,ret.getString(j),detFormat);sheet.addCell(l);//sheet.setColumnView(j,30);}}workbook.write();workbook.close();}catch(Exceptione){}}catch(SQLExceptionae){thrownewApplicationException("创立Excel时查询数据库操纵失利!"+"毛病信息:"+strSql+",非常信息为:
"+ae.getMessage());}finally{closeResultSet(ret);closeStatement(pstmt);closeConnection();}}
有了这样一个呼声:让java代替C语言成为基本语言。这些足以说明java简单易学的这个优点。其次,java的功能强大,前面我也提到了,EJB3.0的推出使java成为了大型项目的首选。 |
|