乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > java操作poi的excel表格的线条怎么变为黑色?-poi设置excel单元格格式设置,poi设置单元格格式为数字

java操作poi的excel表格的线条怎么变为黑色?-poi设置excel单元格格式设置,poi设置单元格格式为数字

作者:乔山办公网日期:

返回目录:excel表格制作


应该是没有、 这也好实现,自己写个方法,循环每一个单元格来弄吧

Java中设置表格边线颜色e69da5e887aae79fa5e98193332

  1. import com.spire.xls.*;

  2. import java.awt.*;

  3.  

  4. public class AddBorders {

  5.     public static void main(String[] args){

  6.         //Create a workbook instance

  7.         Workbook workbook = new Workbook();

  8.         //Load the Excel file

  9.         workbook.loadFromFile("Sample-SetBorder.xlsx");

  10.  

  11.         //Get the first worksheet

  12.         Worksheet sheet = workbook.getWorksheets().get(0);

  13.  

  14.         //Get the cell range that you want to apply border style

  15.         CellRange cr = sheet.getCellRange(sheet.getFirstRow(), sheet.getFirstColumn(), sheet.getLastRow(), sheet.getLastColumn());

  16.  

  17.         //Apply border style

  18.         cr.getBorders().setLineStyle(LineStyleType.Double);

  19.         cr.getBorders().getByBordersLineType(BordersLineType.DiagonalDown).setLineStyle(LineStyleType.None);

  20.         cr.getBorders().getByBordersLineType(BordersLineType.DiagonalUp).setLineStyle(LineStyleType.None);

  21.         cr.getBorders().setColor(Color.BLUE);

  22.  

  23.         //Save the resultant file

  24.         workbook.saveToFile("SetBorder.xlsx", ExcelVersion.Version2010);

  25.     }

  26. }

参考自:网页链接


参考 public static void createColHeader(HSSFSheet sheet, CellStyle cellStyle,String[] columHeader) {if (sheet != null) { sheet.setDefaultColumnWidth(20); HSSFRow row = sheet.createRow(0); for (int i = 0; i < columHeader.length; i++) { HSSFCell cell = row.createCell(i); cell.setCellValue(columHeader[i]); if (cellStyle != null) { cell.setCellStyle(cellStyle); } } freezePane(sheet,0,1,0,1); }}

cellStyle.setAlignment(HSSFCellStyle.ALIGN_JUSTIFY);
cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框

相关阅读

关键词不能为空
极力推荐
  • excel2013-Excel超实用7个小技巧

  • 以下技巧均以Excel2013为例,过程如下:技巧1、单元格内强制换行技巧2、隐藏或显示0值技巧3、隐藏单元格所有值技巧4、单元格数值固定最小长度技巧5、合并多个单元格内容技巧6、快速

ppt怎么做_excel表格制作_office365_word文档_365办公网