andyj2ee

          java tec sky

          統計

          留言簿(4)

          activemq

          aop

          design pattern

          other blog

          spring

          workflow

          多線程

          軟件架構師

          閱讀排行榜

          評論排行榜

          jasperreport 0.6.8 生成 excel 報表,目前還不能支持圖片

          在 jasperreports-0.6.8\lib 中,使用的apache poi 版本: poi-2.0-final-20040126.jar  
          此版本poi 還不支持圖片的處理。
          到現在 poi 3.0 alphal 已經發布,(2005-07-04) 這個版本已經加入插入圖片的功能。
          下載原代碼:http://apache.freelamp.com/jakarta/poi/dev/src/ poi-src-3.0-alpha1-20050704.zip  
          詳細查看 sample 部分
          src/examples/src
          org.apache.poi.hssf.usermodel.examples
          OfficeDrawing

          于2005-05-01加入了新的示例代碼:drawSheet5
          public class OfficeDrawing
          {
              
          public static void main(String[] args)
                  throws IOException
              
          {
          // Create the workbook and sheets.
                  HSSFWorkbook wb = new HSSFWorkbook();
          HSSFSheet sheet5 
          = wb.createSheet("fifth sheet");
          drawSheet5( sheet5, wb );

          // Write the file out.
                  FileOutputStream fileOut = new FileOutputStream("workbook.xls");
                  wb.write(fileOut);
                  fileOut.close();
              }


          private static void drawSheet5( HSSFSheet sheet5, HSSFWorkbook wb ) throws IOException
              
          {

                  
          // Create the drawing patriarch.  This is the top level container for
                  
          // all shapes. This will clear out any existing shapes for that sheet.
                  HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();

                  HSSFClientAnchor anchor;
                  anchor 
          = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7);
                  anchor.setAnchorType( 
          2 );
                  patriarch.createPicture(anchor, loadPicture( 
          "src/resources/logos/logoKarmokar4.png", wb ));

                  anchor 
          = new HSSFClientAnchor(0,0,0,255,(short)4,2,(short)5,7);
                  anchor.setAnchorType( 
          2 );
                  patriarch.createPicture(anchor, loadPicture( 
          "src/resources/logos/logoKarmokar4edited.png", wb ));

                  anchor 
          = new HSSFClientAnchor(0,0,1023,255,(short)6,2,(short)8,7);
                  anchor.setAnchorType( 
          2 );
                  HSSFPicture picture 
          = patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4s.png", wb ));
                  picture.setLineStyle( picture.LINESTYLE_DASHDOTGEL );

              }


          private static int loadPicture( String path, HSSFWorkbook wb ) throws IOException
              
          {
                  
          int pictureIndex;
                  FileInputStream fis 
          = null;
                  ByteArrayOutputStream bos 
          = null;
                  
          try
                  
          {
                      fis 
          = new FileInputStream( path);
                      bos 
          = new ByteArrayOutputStream( );
                      
          int c;
                      
          while ( (c = fis.read()) != -1)
                          bos.write( c );
                      pictureIndex 
          = wb.addPicture( bos.toByteArray(), HSSFWorkbook.PICTURE_TYPE_PNG );
                  }

                  
          finally
                  
          {
                      
          if (fis != null)
                          fis.close();
                      
          if (bos != null)
                          bos.close();
                  }

                  
          return pictureIndex;
              }


          }


          方向:分布式系統設計

          posted on 2005-07-13 14:28 java光環 閱讀(1255) 評論(0)  編輯  收藏 所屬分類: 報表


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 怀安县| 大足县| 黎城县| 长宁区| 白山市| 阿图什市| 禹城市| 延长县| 磐安县| 区。| 九龙县| 宽甸| 三穗县| 莆田市| 漳州市| 四平市| 岱山县| 双江| 潜山县| 呼图壁县| 黄梅县| 天长市| 西盟| 沈丘县| 四子王旗| 奉节县| 安西县| 安化县| 白朗县| 晋城| 高青县| 平果县| 千阳县| 黄大仙区| 长岛县| 开化县| 嘉荫县| 杭锦后旗| 蓝山县| 定兴县| 清涧县|