POI导出Excel划斜线

来源:互联网 发布:北京企业老板数据 编辑:程序博客网 时间:2024/05/05 03:34
public class Test{/** * @param args * @throws FileNotFoundException  */public static void main(String[] args) throws FileNotFoundException{HSSFWorkbook workbook = new HSSFWorkbook();HSSFSheet sheet = workbook.createSheet();HSSFRow row = sheet.createRow(0) ;row.setHeight((short) 500) ;sheet.setColumnWidth(0, 4000) ;HSSFCellStyle cellStyle = workbook.createCellStyle() ;cellStyle.setWrapText(true);cellStyle.setAlignment((short)2) ;cellStyle.setVerticalAlignment((short)1) ;HSSFCell cell = row.createCell(0) ;cell.setCellValue("姓名            密码") ;cell.setCellStyle(cellStyle) ;//画线(由左上到右下的斜线)HSSFPatriarch patriarch = sheet.createDrawingPatriarch();HSSFClientAnchor a = new HSSFClientAnchor(0, 0, 1023, 255, (short)0, 0, (short)0, 0);HSSFSimpleShape shape1 = patriarch.createSimpleShape(a);shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); shape1.setLineStyle(HSSFSimpleShape.LINESTYLE_SOLID) ;OutputStream outputStream = new  FileOutputStream("C:\\test.xls") ;try{workbook.write(outputStream);}catch (IOException e){e.printStackTrace();}System.out.println("generate  excel success ! ");}}


原创粉丝点击