客户需求,导出excel要有个反斜线,往上很多方法画斜线可以,反斜线不行,找了一天,终于找到了解决方法,分享一下:
/
/ 创建绘图对象 画反斜线
Drawing drawing = sheet.createDrawingPatriarch();
// 创建斜线
XSSFDrawing xssfdrawing = sheet.getDrawingPatriarch();
CreationHelper helper = web.getCreationHelper();
ClientAnchor anchor = helper.createClientAnchor();
// 设置斜线的开始位置
anchor.setRow1(1);
anchor.setCol1(1);
// 设置斜线的结束位置
anchor.setRow2(2);
anchor.setCol2(2);
if (drawing instanceof XSSFDrawing){
XSSFSimpleShape shape = ((XSSFDrawing) drawing).createSimpleShape((XSSFClientAnchor)anchor);
shape.setShapeType(2);// 1 左上开始右下结束 2右上开始,左下结束
shape.setLineWidth(0.5);
shape.setLineStyle(0);
shape.setLineStyleColor(255,0,0);
}