@Grab(group='org.apache.poi', module='poi', version='3.9') import org.apache.poi.hssf.usermodel.*; workbook = new HSSFWorkbook() sheet = workbook.createSheet("sheet1") HSSFPatriarch patriarch = sheet.createDrawingPatriarch() // 四角形を描画 ca1 = new HSSFClientAnchor( 0, 0, 0, 0, /* top-left */ (short)1, 2, /* right-bottom */ (short)3, 4 ) ca1.setAnchorType(ca1.MOVE_DONT_RESIZE) shape1 = patriarch.createSimpleShape(ca1) shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE) // 線の色を設定 shape1.setLineStyleColor(0x77, 0x99, 0xdd) // 塗りつぶし色を設定 shape1.setFillColor(0xcc, 0xdd, 0xff) // 線を描画 ca2 = new HSSFClientAnchor( 0, 0, 0, 0, (short) 1, 5, (short) 3, 5 ) ca2.setAnchorType(ca2.MOVE_DONT_RESIZE) shape2 = patriarch.createSimpleShape(ca2) shape2.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE) // ラインスタイルを点線に設定 shape2.setLineStyle(HSSFShape.LINESTYLE_DOTSYS) // 楕円を描画 ca3 = new HSSFClientAnchor( 0, 0, 0, 0, (short) 1, 6, (short) 3, 8 ) ca3.setAnchorType(ca3.MOVE_DONT_RESIZE) shape3 = patriarch.createSimpleShape(ca3) shape3.setShapeType(HSSFSimpleShape.OBJECT_TYPE_OVAL) // 線の太さを設定 12700=1Pt shape3.setLineWidth(12700*3) workbook.write(new FileOutputStream("test.xls"))出力excelファイル
動作環境
groovy 2.1.7, JDK7 update40
0 件のコメント:
コメントを投稿