Java输出箭头_java基于XSSF 导出带箭头的直线
代碼:
XSSFSheet sheet = workbook.getSheetAt(0);
XSSFDrawing patriarch = sheet.createDrawingPatriarch(); //頂級畫布,只能有一個
//設(shè)置錨點(坐標(biāo)),
// XSSFClientAnchor的參數(shù)說明:
// 參數(shù) 說明
// dx1 第1個單元格中x軸的偏移量
// dy1 第1個單元格中y軸的偏移量
// dx2 第2個單元格中x軸的偏移量
// dy2 第2個單元格中y軸的偏移量
// col1 第1個單元格的列號
// row1 第1個單元格的行號
// col2 第2個單元格的列號
// row2 第2個單元格的行號
XSSFClientAnchor anchor = new XSSFClientAnchor(0,75000,0,75000,(short) 10, 5,(short)15,10);
XSSFSimpleShape rec = patriarch.createSimpleShape(anchor);
rec.setShapeType( ShapeTypes.LINE ); //設(shè)置圖形 形狀(直線),其余參考 官方api
// 線的類型
// solid=0 (實線)、dot=1( 點)、dash=2 (點劃線)、lgDash=3、dashDot=4、lgDashDot=5、
// lgDashDotDot=6、sysDash=7、sysDot=8、sysDashDot=9、sysDashDotDot=10
rec.setLineStyle(2); //(點劃線 )
rec.setLineStyleColor(65, 113, 156);//設(shè)置邊框顏色
rec.setLineWidth(1.5); //線寬
/************下面代碼設(shè)置箭頭,不需要箭頭的話 無需這些代碼 **************/
rec.getCTShape().getNvSpPr().getCNvPr().setId(rec.getCTShape().getNvSpPr().getCNvPr().getId()-1);
CTShapeProperties shapeProperties = rec.getCTShape().getSpPr();
CTLineEndProperties lineEndPropertiesTriangle = org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties.Factory.newInstance();
lineEndPropertiesTriangle.setType(STLineEndType.TRIANGLE);
lineEndPropertiesTriangle.setLen(STLineEndLength.MED);
lineEndPropertiesTriangle.setW(STLineEndWidth.MED);
CTLineProperties lineProperties = shapeProperties.getLn();
lineProperties.setHeadEnd(lineEndPropertiesTriangle); //頭部箭頭
lineProperties.setTailEnd(lineEndPropertiesTriangle); //尾部箭頭
如果要設(shè)置豎線箭頭 ,設(shè)置導(dǎo)出時的列為 同一列
總結(jié)
以上是生活随笔為你收集整理的Java输出箭头_java基于XSSF 导出带箭头的直线的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c语言除法加括号么,算不了除法,为什么?
- 下一篇: mysql 结束符报错_【踩坑记录】My