锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产色综合网,久久精品播放,中文字幕在线影视资源http://www.aygfsteel.com/LoveAngela/category/52857.html琛ㄩ潰鐨勬縺鐑堟槸鐢變簬鍐呭績鐨勫崟钖勶紝鐪熸鐨勫姏閲忓鍚屾祦姘翠竴鑸矇闈?/description>zh-cnMon, 22 Oct 2012 07:29:51 GMTMon, 22 Oct 2012 07:29:51 GMT60POI Excel灝忓伐鍏風被http://www.aygfsteel.com/LoveAngela/articles/389969.html鐡㈣彎鐨勯洦澶?/dc:creator>鐡㈣彎鐨勯洦澶?/author>Sun, 21 Oct 2012 09:43:00 GMThttp://www.aygfsteel.com/LoveAngela/articles/389969.htmlhttp://www.aygfsteel.com/LoveAngela/comments/389969.htmlhttp://www.aygfsteel.com/LoveAngela/articles/389969.html#Feedback0http://www.aygfsteel.com/LoveAngela/comments/commentRss/389969.htmlhttp://www.aygfsteel.com/LoveAngela/services/trackbacks/389969.html  1 package poi.excel;
  2 
  3 import java.awt.Graphics;
  4 import java.awt.Image;
  5 import java.awt.image.BufferedImage;
  6 import java.io.ByteArrayOutputStream;
  7 import java.io.FileInputStream;
  8 import java.io.IOException;
  9 import javax.imageio.ImageIO;
 10 import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
 11 import org.apache.poi.hssf.usermodel.HSSFPatriarch;
 12 import org.apache.poi.hssf.usermodel.HSSFPicture;
 13 import org.apache.poi.hssf.usermodel.HSSFSheet;
 14 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 15 
 16 /**
 17  * poi HSSF 鎻愬彇鐐規柟娉?br /> 18  * @author sikaijian
 19  */
 20 public class Excel03Util {
 21     /**
 22      * 鐢誨浘鐗?br /> 23      * @param sheet
 24      * @param wb
 25      * @param startCol
 26      * @param startRow
 27      * @param endCol
 28      * @param endRow
 29      * @param pictureIndex 鍥劇墖绱㈠紩鍙?nbsp;闇瑕佸厛鍦╳orkbook涓姞鍏ュ浘鐗囪祫婧?br /> 30      * @throws IOException
 31      * @author sikaijian
 32      */
 33     public static void drawPicture(HSSFSheet sheet, HSSFWorkbook wb,
 34             short startCol, int startRow, short endCol, int endRow,
 35             int pictureIndex) throws IOException {
 36         // 鍥劇墖瀹瑰櫒
 37         HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
 38         
 39         // 閿氱偣 瀹瑰櫒涓嬮敋浣嶇疆
 40         HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 255, startCol,
 41                 startRow, endCol, endRow);
 42         anchor.setAnchorType(2);
 43         
 44         // 瀹瑰櫒涓嬮敋錛屽茍杞藉叆鍥劇墖
 45         HSSFPicture picture = patriarch.createPicture(anchor, pictureIndex);
 46 
 47         picture.resize();
 48         picture.setLineStyle(picture.LINESTYLE_DASHDOTGEL);
 49     }
 50 
 51     /**
 52      * 鍔犺澆鍥劇墖
 53      * @param img 鍥劇墖瀵硅薄
 54      * @param wb
 55      * @return 鍥劇墖绱㈠紩鍙?br /> 56      * @throws IOException
 57      * @author sikaijian
 58      */
 59     public static int loadPicture(Image img, HSSFWorkbook wb)
 60             throws IOException {
 61         int pictureIndex;
 62         ByteArrayOutputStream arrayOut = null;
 63         try {
 64             arrayOut = new ByteArrayOutputStream();
 65             BufferedImage buImage = new BufferedImage(img.getWidth(null), img
 66                     .getHeight(null), BufferedImage.TYPE_INT_RGB);
 67             Graphics g = buImage.getGraphics();
 68             g.drawImage(img, 0, 0, null);
 69             ImageIO.write(buImage, "png", arrayOut);
 70 
 71             byte[] data = arrayOut.toByteArray();
 72 
 73             pictureIndex = wb.addPicture(data, HSSFWorkbook.PICTURE_TYPE_PNG);
 74         } finally {
 75             if (null != arrayOut) {
 76                 arrayOut.close();
 77             }
 78         }
 79 
 80         return pictureIndex;
 81     }
 82 
 83     /**
 84      * 鍔犺澆鍥劇墖
 85      * @param path 鍥劇墖璺緞
 86      * @param wb
 87      * @return 鍥劇墖绱㈠紩鍙?br /> 88      * @throws IOException
 89      */
 90     public static int loadPicture(String path, HSSFWorkbook wb)
 91             throws IOException {
 92         int pictureIndex;
 93         FileInputStream fis = null;
 94         ByteArrayOutputStream bos = null;
 95         try {
 96             fis = new FileInputStream(path);
 97             bos = new ByteArrayOutputStream();
 98             int c;
 99             while ((c = fis.read()) != -1)
100                 bos.write(c);
101             pictureIndex = wb.addPicture(bos.toByteArray(),
102                     HSSFWorkbook.PICTURE_TYPE_PNG);
103         } finally {
104             if (fis != null)
105                 fis.close();
106             if (bos != null)
107                 bos.close();
108         }
109         return pictureIndex;
110     }
111 }
112 

]]>
主站蜘蛛池模板: 什邡市| 万年县| 青田县| 康定县| 汉阴县| 泰州市| 井冈山市| 邯郸县| 政和县| 集安市| 泗水县| 阿克苏市| 永年县| 巴彦淖尔市| 芜湖市| 浦东新区| 绥棱县| 通辽市| 繁峙县| 堆龙德庆县| 瑞丽市| 石门县| 绥棱县| 洛扎县| 萍乡市| 克什克腾旗| 顺平县| 绵竹市| 辽源市| 临颍县| 青海省| 磐石市| 犍为县| 皋兰县| 皮山县| 南汇区| 双辽市| 宁波市| 辉南县| 霍州市| 乌兰县|