返回目录:excel表格制作
应该是没有、 这也好实现,自己写个方法,循环每一个单元格来弄吧
Java中设置表格边线颜色e69da5e887aae79fa5e98193332:
import com.spire.xls.*;
import java.awt.*;
public class AddBorders {
public static void main(String[] args){
//Create a workbook instance
Workbook workbook = new Workbook();
//Load the Excel file
workbook.loadFromFile("Sample-SetBorder.xlsx");
//Get the first worksheet
Worksheet sheet = workbook.getWorksheets().get(0);
//Get the cell range that you want to apply border style
CellRange cr = sheet.getCellRange(sheet.getFirstRow(), sheet.getFirstColumn(), sheet.getLastRow(), sheet.getLastColumn());
//Apply border style
cr.getBorders().setLineStyle(LineStyleType.Double);
cr.getBorders().getByBordersLineType(BordersLineType.DiagonalDown).setLineStyle(LineStyleType.None);
cr.getBorders().getByBordersLineType(BordersLineType.DiagonalUp).setLineStyle(LineStyleType.None);
cr.getBorders().setColor(Color.BLUE);
//Save the resultant file
workbook.saveToFile("SetBorder.xlsx", ExcelVersion.Version2010);
}
}
参考自:网页链接
参考自代百码度知 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);// 右边框