com.eworkcloud.excel.style.DefaultStyle Maven / Gradle / Ivy
package com.eworkcloud.excel.style;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
public class DefaultStyle implements ExportStyle {
@Override
public CellStyle titleStyle(Workbook workbook) {
Font font = workbook.createFont();
font.setFontName("Arial");
font.setFontHeightInPoints((short) 13);
font.setBold(true);
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setWrapText(true);
cellStyle.setFont(font);
return cellStyle;
}
@Override
public CellStyle headerStyle(Workbook workbook, boolean required) {
Font font = workbook.createFont();
font.setFontName("Arial");
font.setFontHeightInPoints((short) 11);
font.setBold(true);
if (required) {
font.setColor(Font.COLOR_RED);
}
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setWrapText(true);
cellStyle.setFont(font);
return cellStyle;
}
@Override
public CellStyle alignLeft(Workbook workbook, boolean isWrap) {
Font font = workbook.createFont();
font.setFontName("Arial");
font.setFontHeightInPoints((short) 11);
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.LEFT);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setWrapText(isWrap);
cellStyle.setFont(font);
return cellStyle;
}
@Override
public CellStyle alignRight(Workbook workbook, boolean isWrap) {
Font font = workbook.createFont();
font.setFontName("Arial");
font.setFontHeightInPoints((short) 11);
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.RIGHT);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setWrapText(isWrap);
cellStyle.setFont(font);
return cellStyle;
}
@Override
public CellStyle alignCenter(Workbook workbook, boolean isWrap) {
Font font = workbook.createFont();
font.setFontName("Arial");
font.setFontHeightInPoints((short) 11);
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setWrapText(isWrap);
cellStyle.setFont(font);
return cellStyle;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy