700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > poi excel 导出设置边框 自定义背景色 自定义字体

poi excel 导出设置边框 自定义背景色 自定义字体

时间:2022-04-21 00:34:35

相关推荐

poi excel 导出设置边框 自定义背景色 自定义字体

HSSFCellStyle style = changeStyleByCreditExport(workbook, "仿宋",12," 204, 204, 255");HSSFCell cell = row.createCell(0);cell.setCellValue("值");cell.setCellStyle(style);

private HSSFCellStyle changeStyleByCreditExport(HSSFWorkbook workbook, String fontName,int fontSize,String rgbColor){HSSFCellStyle style = workbook.createCellStyle();String[] rgb = rgbColor.split(",");int r = Integer.parseInt(rgb[0].trim());int g = Integer.parseInt(rgb[1].trim());int b = Integer.parseInt(rgb[2].trim());HSSFPalette palette = workbook.getCustomPalette();//这个是重点,具体的就是把之前的颜色 HSSFColor.LIME.index//HSSFColor.PALE_BLUE.index//替换为 RGB(51,204,204) 宝石蓝这种颜色//你可以改为 RGB(0,255,127)204, 204, 255palette.setColorAtIndex(HSSFColor.LIME.index, (byte)r,(byte)g,(byte)b);short backgroundColor = palette.getColor(HSSFColor.LIME.index).getIndex();style.setFillForegroundColor(backgroundColor);//HSSFColor.PALE_BLUE.indexstyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);//设置下边框的线条粗细(有14种选择,可以根据需要在BorderStyle这个类中选取)style.setBorderBottom(BorderStyle.THIN);//设置下边框的边框线颜色(颜色和上述的颜色对照表是一样的)style.setBottomBorderColor(IndexedColors.BLACK.getIndex());style.setBorderLeft(BorderStyle.THIN);//左边框style.setLeftBorderColor(IndexedColors.BLACK.getIndex());style.setBorderTop(BorderStyle.THIN); //上边框style.setRightBorderColor(IndexedColors.BLACK.getIndex());style.setBorderRight(BorderStyle.THIN);//右边框style.setTopBorderColor(IndexedColors.BLACK.getIndex());Font font = workbook.createFont();//true为加粗,默认为不加粗// font.setBold(true);//设置字体颜色,颜色和上述的颜色对照表是一样的font.setColor(IndexedColors.BLACK.getIndex());font.setFontName(fontName);// font.setFontName("仿宋_GB2312");// font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示font.setFontHeightInPoints((short) fontSize); //字体大小//将字体样式设置到单元格样式中style.setFont(font);style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 居中style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中style.setWrapText(true);//自动换行return style;}

单元格合并

poi excel 下拉框 单元格合并_woodking-CSDN博客poi excel 下拉框 单元格合并/qq_33443020/article/details/121967976?spm=1001..3001.5501

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。