「javapoi边框」javafx边框
今天给各位分享javapoi边框的知识,其中也会对javafx边框进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、java操作poi的excel表格的线条怎么变为黑色?
- 2、java poi 给指定的行列加个边框,怎么加。
- 3、java poi3.9 怎么设置单元格边框 请各位大神帮帮忙!小弟非常感谢,最好详细点
java操作poi的excel表格的线条怎么变为黑色?
你跑下下面的代码试下吧:\x0d\x0apublic TestExcel(){\x0d\x0a createExcelFile();\x0d\x0a }\x0d\x0a \x0d\x0a private void createExcelFile() {\x0d\x0a HSSFWorkbook hwb = new HSSFWorkbook();\x0d\x0a HSSFSheet sheet = hwb.createSheet("test sheet");\x0d\x0a //创建一个样式\x0d\x0a HSSFCellStyle style = hwb.createCellStyle();\x0d\x0a //设置边框样式\x0d\x0a style.setBorderTop(HSSFCellStyle.BORDER_THIN);\x0d\x0a style.setBorderBottom(HSSFCellStyle.BORDER_THIN);\x0d\x0a style.setBorderLeft(HSSFCellStyle.BORDER_THIN);\x0d\x0a style.setBorderRight(HSSFCellStyle.BORDER_THIN);\x0d\x0a //设置边框颜色\x0d\x0a style.setTopBorderColor(HSSFColor.BLACK.index);\x0d\x0a style.setBottomBorderColor(HSSFColor.BLACK.index);\x0d\x0a style.setLeftBorderColor(HSSFColor.BLACK.index);\x0d\x0a style.setRightBorderColor(HSSFColor.BLACK.index);\x0d\x0a \x0d\x0a for(int j=0;j
回答于 2022-11-16
java poi 给指定的行列加个边框,怎么加。
你可以参考下这个代码:
Workbook workbook=new HSSFWorkbook(); // 定义一个新的工作簿
Sheet sheet=workbook.createSheet("第一个Sheet页"); // 创建第一个Sheet页
Row row=sheet.createRow(1); // 创建一个行
Cell cell=row.createCell(1); // 创建一个单元格
cell.setCellValue(4);
// 设置单元格边框
CellStyle cellStyle=workbook.createCellStyle();
cellStyle.setBorderBottom(CellStyle.BORDER_THIN); // 底部边框
cellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex()); // 底部边框颜色
cellStyle.setBorderLeft(CellStyle.BORDER_THIN); // 左边边框
cellStyle.setLeftBorderColor(IndexedColors.GREEN.getIndex()); // 左边边框颜色
cellStyle.setBorderRight(CellStyle.BORDER_THIN); // 右边边框
cellStyle.setRightBorderColor(IndexedColors.BLUE.getIndex()); // 右边边框颜色
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED); // 上边边框
cellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex()); // 上边边框颜色
java poi3.9 怎么设置单元格边框 请各位大神帮帮忙!小弟非常感谢,最好详细点
/**
* 表头样式
* @param workbook
* @param sheet
* @return
*/
private HSSFCellStyle createTitleStytle(HSSFWorkbook workbook,HSSFSheet sheet){
HSSFCellStyle style2 = workbook.createCellStyle();
style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
// 生成另一个字体
HSSFFont font2 = workbook.createFont();
font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
font2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font2.setFontHeightInPoints((short) 16);
// 把字体应用到当前的样式
style2.setFont(font2);
//边框
style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style2.setBorderRight(HSSFCellStyle.BORDER_THIN);
style2.setBorderTop(HSSFCellStyle.BORDER_THIN);
style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
return style2;
}
来自我的项目的一个方法,慎用
javapoi边框的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于javafx边框、javapoi边框的信息别忘了在本站进行查找喔。