Commit 3a81b600 authored by liyuan.chen's avatar liyuan.chen

对账单修改

parent 989e2f6a
......@@ -19,11 +19,6 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
* excle样式工具类
* @author linry
*
*/
public class ExcelFormatUtil {
/**
* 设置报表头样式
......@@ -31,26 +26,15 @@ public class ExcelFormatUtil {
* @return
*/
public static CellStyle headSytle(SXSSFWorkbook workbook){
// 设置style1的样式,此样式运用在第二行
CellStyle style1 = workbook.createCellStyle();// cell样式
// 设置单元格背景色,设置单元格背景色以下两句必须同时设置
/*style1.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);// 设置填充样式
style1.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);// 设置填充色*/
// 设置单元格上、下、左、右的边框线
/*style1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style1.setBorderRight(HSSFCellStyle.BORDER_THIN);
style1.setBorderTop(HSSFCellStyle.BORDER_THIN);*/
Font font1 = workbook.createFont();// 创建一个字体对象
CellStyle style1 = workbook.createCellStyle();
Font font1 = workbook.createFont();
font1.setBold(true);
//font1.setBoldweight((short) 16);// 设置字体的宽度
font1.setFontHeightInPoints((short) 16);// 设置字体的高度
font1.setFontName("等线");
//font1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 粗体显示
style1.setFont(font1);// 设置style1的字体
style1.setWrapText(true);// 设置自动换行
style1.setAlignment(HorizontalAlignment.CENTER);// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格字体显示居中(上下方向)
font1.setFontHeightInPoints((short) 16);
font1.setFontName("黑体");
style1.setFont(font1);
style1.setWrapText(true);
style1.setAlignment(HorizontalAlignment.CENTER);
style1.setVerticalAlignment(VerticalAlignment.CENTER);
return style1;
}
/**
......@@ -58,89 +42,69 @@ public class ExcelFormatUtil {
* @param wb
* @return
*/
// 黑体加粗居左显示
public static CellStyle contentBpStyle(SXSSFWorkbook wb){
CellStyle style1 = wb.createCellStyle();
Font font1 = wb.createFont();
font1.setBold(true);
font1.setFontName("黑体");
style1.setFont(font1);
//style1.setBorderBottom(BorderStyle.THIN);
style1.setWrapText(true);
style1.setAlignment(HorizontalAlignment.LEFT);
style1.setVerticalAlignment(VerticalAlignment.CENTER);
return style1;
}
// 黑体居左显示
public static CellStyle contentStyle(SXSSFWorkbook wb){
// 设置style1的样式,此样式运用在第二行
CellStyle style1 = wb.createCellStyle();// cell样式
// 设置单元格上、下、左、右的边框线
/*style1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style1.setBorderRight(HSSFCellStyle.BORDER_THIN);
style1.setBorderTop(HSSFCellStyle.BORDER_THIN);*/
//style1.setWrapText(true);// 设置自动换行
style1.setAlignment(HorizontalAlignment.LEFT);// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格字体显示居中(上下方向)
CellStyle style1 = wb.createCellStyle();
Font font1 = wb.createFont();
font1.setFontName("黑体");
style1.setFont(font1);
//style1.setWrapText(true);
style1.setAlignment(HorizontalAlignment.LEFT);
style1.setVerticalAlignment(VerticalAlignment.CENTER);
return style1;
}
public static CellStyle contentStyleLine(SXSSFWorkbook wb){
// 设置style1的样式,此样式运用在第二行
CellStyle style1 = wb.createCellStyle();// cell样式
// 设置单元格上、下、左、右的边框线
style1.setBorderBottom(BorderStyle.THIN);
/* style1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style1.setBorderRight(HSSFCellStyle.BORDER_THIN);
style1.setBorderTop(HSSFCellStyle.BORDER_THIN);*/
style1.setWrapText(true);// 设置自动换行
style1.setAlignment(HorizontalAlignment.LEFT);// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格字体显示居中(上下方向)
// 黑体居中显示
public static CellStyle contentCenterStyle(SXSSFWorkbook wb){
CellStyle style1 = wb.createCellStyle();
Font font1 = wb.createFont();
font1.setFontName("黑体");
style1.setFont(font1);
style1.setWrapText(true);
style1.setAlignment(HorizontalAlignment.CENTER);
style1.setVerticalAlignment(VerticalAlignment.CENTER);
return style1;
}
public static CellStyle contentTableStyle(SXSSFWorkbook wb){
// 设置style1的样式,此样式运用在第二行
CellStyle style1 = wb.createCellStyle();// cell样式
// 设置单元格上、下、左、右的边框线
// 黑体加下边框线显示
public static CellStyle contentStyleLine(SXSSFWorkbook wb){
CellStyle style1 = wb.createCellStyle();
Font font1 = wb.createFont();
font1.setFontName("黑体");
style1.setFont(font1);
style1.setBorderBottom(BorderStyle.THIN);
style1.setBorderLeft(BorderStyle.THIN);
style1.setBorderRight(BorderStyle.THIN);
style1.setBorderTop(BorderStyle.THIN);
style1.setWrapText(true);// 设置自动换行
style1.setAlignment(HorizontalAlignment.CENTER);// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格字体显示居中(上下方向)
//style1.setWrapText(true);
style1.setAlignment(HorizontalAlignment.LEFT);
style1.setVerticalAlignment(VerticalAlignment.CENTER);
return style1;
}
/**
* 设置报表标题样式
* @param workbook
* @return
*/
public static HSSFCellStyle titleSytle(HSSFWorkbook workbook,short color,short fontSize){
// 设置style1的样式,此样式运用在第二行
HSSFCellStyle style1 = workbook.createCellStyle();// cell样式
// 设置单元格背景色,设置单元格背景色以下两句必须同时设置
//style1.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);// 设置填充样式
//short fcolor = color;
// 设置单元格上、下、左、右的边框线
// 列表维持原等线字体
public static CellStyle contentTableStyle(SXSSFWorkbook wb){
CellStyle style1 = wb.createCellStyle();
Font font1 = wb.createFont();
font1.setFontName("等线");
style1.setFont(font1);
style1.setBorderBottom(BorderStyle.THIN);
style1.setBorderLeft(BorderStyle.THIN);
style1.setBorderRight(BorderStyle.THIN);
style1.setBorderTop(BorderStyle.THIN);
HSSFFont font1 = workbook.createFont();// 创建一个字体对象
font1.setBold(true);
font1.setFontHeightInPoints(fontSize);// 设置字体的高度
style1.setFont(font1);// 设置style1的字体
style1.setWrapText(true);// 设置自动换行
style1.setAlignment(HorizontalAlignment.CENTER);// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格字体显示居中(上下方向)
style1.setWrapText(true);
style1.setAlignment(HorizontalAlignment.CENTER);
style1.setVerticalAlignment(VerticalAlignment.CENTER);
return style1;
}
/**
*设置表头
* @param sheet
*/
public static void initTitleEX(SXSSFSheet sheet, CellStyle header,String title[],int titleLength[]) {
SXSSFRow row0 = sheet.createRow(0);
row0.setHeight((short) 800);
for(int j = 0;j<title.length; j++) {
SXSSFCell cell = row0.createCell(j);
//设置每一列的字段名
cell.setCellValue(title[j]);
cell.setCellStyle(header);
sheet.setColumnWidth(j, titleLength[j]);
}
}
/**
*设置表头
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment