本文整理汇总了Java中org.apache.poi.xssf.usermodel.XSSFCellStyle.setAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java XSSFCellStyle.setAlignment方法的具体用法?Java XSSFCellStyle.setAlignment怎么用?Java XSSFCellStyle.setAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.xssf.usermodel.XSSFCellStyle
的用法示例。
在下文中一共展示了XSSFCellStyle.setAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBackgroundColorXSSFCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
/**
* @param wb
* @param color
* @param foreGround
* @return
*/
public static XSSFCellStyle createBackgroundColorXSSFCellStyle(XSSFWorkbook wb,XSSFColor color,short foreGround){
String message="XSSFWorkbook must not be null!";
Objects.requireNonNull(wb, () -> message);
XSSFCellStyle cellStyle=wb.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setFillForegroundColor(color);
cellStyle.setFillPattern(foreGround);
return cellStyle;
}
示例2: createSheetRow
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
/**
* Creates a new line with values in the sheet.
*
* @param workbook
* (XSSFWorkbook, required) workbook to create the row in
* @param sheetRow
* (XSSFSheetRow, required) sheet to create the data row in
* @param sheetName
* (String, required) name of the sheet
* @param values
* (String [], optional) if null or empty no work will be done, else the values written to the next line
* @param bold
* (boolean) true: the values will be set in bold font face, else normal
*
* @since 2.0.10
*/
private void createSheetRow(XSSFWorkbook workbook, XSSFSheetRow sheetRow, String sheetName, List<String> values,
boolean bold)
{
if (null != values && values.size() > 0)
{
// check if sheet exists and create if not
if (null == sheetRow.sheet)
{
sheetRow.sheet = workbook.createSheet(sheetName);
}
// create cell style
XSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
if (bold)
{
// Create bold font
Font fontBold = workbook.createFont();
fontBold.setBoldweight(Font.BOLDWEIGHT_BOLD);
cellStyle.setFont(fontBold);
}
// create row
XSSFRow row = sheetRow.sheet.createRow(sheetRow.rowCount++);
// set values
for (int i = 0; i < values.size(); i++)
{
row.getCell(i).setCellValue(values.get(i));
row.getCell(i).setCellStyle(cellStyle);
}
}
}
示例3: getCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
/**
* Fixed all properties suitable for cell-related style.
*
* @param workbook Excel Workbook
* @param boardStyle all properties suitable on the style of a cell
* @param font a font
* @return the customized style
*/
protected static CellStyle getCellStyle(Workbook workbook, TableStyle boardStyle, Font font) {
XSSFCellStyle cellStyle = (XSSFCellStyle) workbook.createCellStyle();
if (boardStyle.getFillColor() != null) {
cellStyle.setFillForegroundColor(boardStyle.getFillColor());
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
}
cellStyle.setBorderLeft(boardStyle.getCellBorderLeft());
cellStyle.setBorderRight(boardStyle.getCellBorderRight());
cellStyle.setBorderTop(boardStyle.getCellBorderTop());
cellStyle.setBorderBottom(boardStyle.getCellBorderBottom());
cellStyle.setAlignment(boardStyle.getAlignment());
cellStyle.setBorderColor(BorderSide.LEFT, boardStyle.getBorderColor());
cellStyle.setBorderColor(BorderSide.RIGHT, boardStyle.getBorderColor());
cellStyle.setBorderColor(BorderSide.TOP, boardStyle.getBorderColor());
cellStyle.setBorderColor(BorderSide.BOTTOM, boardStyle.getBorderColor());
if (font != null) {
cellStyle.setFont(font);
}
return cellStyle;
}
示例4: createTitle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
protected void createTitle() {
short lineThickness = (short) (6 * BASE_HEIGHT);
// Top Line
Row row = sheet.createRow(ROW_4);
row.setHeight(lineThickness);
XSSFCellStyle style = wb.createCellStyle();
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
setDummyTitleStyle(row,style);
// Title
row = sheet.createRow(ROW_5);
row.setHeightInPoints(100);
sheet.addMergedRegion(CellRangeAddress.valueOf("B5:G5"));
Font font = wb.createFont();
font.setFontHeightInPoints((short)28);
font.setFontName("Trebuchet MS");
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
style = wb.createCellStyle();
style.setFont(font);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
setDummyTitleStyle(row,style);
row.getCell(COL_B).setCellValue("Open Source License Verification Report");
// Bottom Line
row = sheet.createRow(ROW_6);
row.setHeight(lineThickness);
style = wb.createCellStyle();
style.setFillForegroundColor(DARK_BLUE);
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
setDummyTitleStyle(row,style);
}
示例5: getCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
/**
* @param color
* @param font
* @return CellStyle
*/
protected XSSFCellStyle getCellStyle(XSSFColor color, Font font) {
XSSFCellStyle style = wb.createCellStyle();
style.setFillForegroundColor(color);
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setWrapText(true); // new line
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderRight(CellStyle.BORDER_THIN);
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderTop(CellStyle.BORDER_THIN);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
if(font != null) style.setFont(font);
return style;
}
示例6: createXSSFCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
public static XSSFCellStyle createXSSFCellStyle(XSSFWorkbook wb){
String message="XSSFWorkbook must not be null!";
Objects.requireNonNull(wb, () -> message);
XSSFCellStyle cellStyle=wb.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
return cellStyle;
}
示例7: createCenterXSSFCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
public static XSSFCellStyle createCenterXSSFCellStyle(XSSFWorkbook wb){
String message="XSSFWorkbook must not be null!";
Objects.requireNonNull(wb, () -> message);
XSSFCellStyle cellStyle=wb.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
return cellStyle;
}
示例8: createXSSFCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
private XSSFCellStyle createXSSFCellStyle(Workbook wb, int[] bgColor, int[] fontColor, int fontSize) {
SXSSFWorkbook workbook = (SXSSFWorkbook) wb;
XSSFFont titleFont = (XSSFFont) workbook.createFont();
titleFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
titleFont.setFontName("宋体");
XSSFColor color9 = new XSSFColor(new java.awt.Color(fontColor[0], fontColor[1], fontColor[2]));
XSSFColor color10 = new XSSFColor(new java.awt.Color(bgColor[0], bgColor[1], bgColor[2]));
if (!(fontColor[0] == 0 && fontColor[1] == 0 && fontColor[2] == 0)) {
titleFont.setColor(color9);
}
titleFont.setBold(true);
titleFont.setFontHeightInPoints((short) fontSize);
XSSFCellStyle titleStyle = (XSSFCellStyle) createBorderCellStyle(workbook, true);
titleStyle.setFont(titleFont);
titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
titleStyle.setFillForegroundColor(color10);
titleStyle.setAlignment(HorizontalAlignment.CENTER);
titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
return titleStyle;
}
示例9: createTitleXSSFCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
public static XSSFCellStyle createTitleXSSFCellStyle(XSSFWorkbook wb){
String message="XSSFWorkbook must not be null!";
Objects.requireNonNull(wb, () -> message);
XSSFCellStyle cellStyle=wb.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setFillForegroundColor(new XSSFColor( new Color(75, 172, 198)));
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
return cellStyle;
}
示例10: accept
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
@Override
public void accept(XSSFCellStyle style) {
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
//전경색
defaultForeGround(style);
}
示例11: setStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
public static XSSFCellStyle setStyle(XSSFWorkbook workbook) {
//设置字体;
XSSFFont font = workbook.createFont();
//设置字体大小;
font.setFontHeightInPoints((short) 20);
//设置字体名字;
font.setFontName("Courier New");
//font.setItalic(true);
//font.setStrikeout(true);
//设置样式;
XSSFCellStyle style = workbook.createCellStyle();
//设置底边框;
style.setBorderBottom(XSSFCellStyle.BORDER_THIN);
//设置底边框颜色;
style.setBottomBorderColor(new XSSFColor(Color.BLACK));
//设置左边框;
style.setBorderLeft(XSSFCellStyle.BORDER_THIN);
//设置左边框颜色;
style.setLeftBorderColor(new XSSFColor(Color.BLACK));
//设置右边框;
style.setBorderRight(XSSFCellStyle.BORDER_THIN);
//设置右边框颜色;
style.setRightBorderColor(new XSSFColor(Color.BLACK));
//设置顶边框;
style.setBorderTop(XSSFCellStyle.BORDER_THIN);
//设置顶边框颜色;
style.setTopBorderColor(new XSSFColor(Color.BLACK));
//在样式用应用设置的字体;
style.setFont(font);
//设置自动换行;
style.setWrapText(false);
//设置水平对齐的样式为居中对齐;
style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
//设置垂直对齐的样式为居中对齐;
style.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
return style;
}
示例12: getCellStyle
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
protected XSSFCellStyle getCellStyle(int border, Font font) {
XSSFCellStyle style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setWrapText(true); // new line
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
if((border & BORDER_BOTTOM) > 0) style.setBorderBottom(CellStyle.BORDER_DOUBLE);
else style.setBorderBottom(CellStyle.BORDER_THIN);
if((border & BORDER_LEFT) > 0) style.setBorderLeft(CellStyle.BORDER_DOUBLE);
else style.setBorderLeft(CellStyle.BORDER_THIN);
if((border & BORDER_RIGHT) > 0) style.setBorderRight(CellStyle.BORDER_DOUBLE);
else style.setBorderRight(CellStyle.BORDER_THIN);
if((border & BORDER_TOP) > 0) style.setBorderTop(CellStyle.BORDER_DOUBLE);
else style.setBorderTop(CellStyle.BORDER_THIN);
if(font != null) style.setFont(font);
return style;
}
示例13: createXSSFCellStyles
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
private Map<String, CellStyle> createXSSFCellStyles(Workbook wb, int[] contextBgColor, int[] contextFontColor, int contextFontSize, int contextFontAlign, int[] headerBgColor,
int[] headerFontColor, int headerFontSize, int headerAlign) {
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
SXSSFWorkbook workbook = (SXSSFWorkbook) wb;
XSSFColor xssfContextBgColor = new XSSFColor(new java.awt.Color(contextBgColor[0], contextBgColor[1], contextBgColor[2]));
XSSFColor xssfContextFontColor = new XSSFColor(new java.awt.Color(contextFontColor[0], contextFontColor[1], contextFontColor[2]));
XSSFColor xssfHeaderBgColor = new XSSFColor(new java.awt.Color(headerBgColor[0], headerBgColor[1], headerBgColor[2]));
XSSFColor xssfHeaderFontColor = new XSSFColor(new java.awt.Color(headerFontColor[0], headerFontColor[1], headerFontColor[2]));
XSSFFont headerFont = (XSSFFont) workbook.createFont();
headerFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
headerFont.setFontName("宋体");
if (!(headerFontColor[0] == 0 && headerFontColor[1] == 0 && headerFontColor[2] == 0)) {
headerFont.setColor(xssfHeaderFontColor);
}
headerFont.setBold(true);
headerFont.setFontHeightInPoints((short) headerFontSize);
XSSFCellStyle headerStyle = (XSSFCellStyle) this.createBorderCellStyle(workbook, true);
headerStyle.setFont(headerFont);
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
headerStyle.setFillForegroundColor(xssfHeaderBgColor);
this.setCellStyleAligment(headerStyle, headerAlign);
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
styles.put(GridStyleType.headerStyle.name(), headerStyle);
XSSFFont dataFont = (XSSFFont) workbook.createFont();
if (!(contextFontColor[0] == 0 && contextFontColor[1] == 0 && contextFontColor[2] == 0)) {
dataFont.setColor(xssfContextFontColor);
}
dataFont.setFontHeightInPoints((short) contextFontSize);
dataFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
dataFont.setFontName("宋体");
XSSFCellStyle dataAlignLeftStyle = (XSSFCellStyle) this.createBorderCellStyle(workbook, true);
dataAlignLeftStyle.setFont(dataFont);
dataAlignLeftStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dataAlignLeftStyle.setFillForegroundColor(xssfContextBgColor);
dataAlignLeftStyle.setVerticalAlignment(VerticalAlignment.CENTER);
dataAlignLeftStyle.setWrapText(true);
dataAlignLeftStyle.setAlignment(HorizontalAlignment.LEFT);
styles.put(GridStyleType.dataAlignLeftStyle.name(), dataAlignLeftStyle);
XSSFCellStyle dataAlignCenterStyle = (XSSFCellStyle) this.createBorderCellStyle(workbook, true);
dataAlignCenterStyle.setFont(dataFont);
dataAlignCenterStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dataAlignCenterStyle.setFillForegroundColor(xssfContextBgColor);
dataAlignCenterStyle.setVerticalAlignment(VerticalAlignment.CENTER);
dataAlignCenterStyle.setWrapText(true);
dataAlignCenterStyle.setAlignment(HorizontalAlignment.CENTER);
styles.put(GridStyleType.dataAlignCenterStyle.name(), dataAlignCenterStyle);
XSSFCellStyle dataAlignRightStyle = (XSSFCellStyle) this.createBorderCellStyle(workbook, true);
dataAlignRightStyle.setFont(dataFont);
dataAlignRightStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dataAlignRightStyle.setFillForegroundColor(xssfContextBgColor);
dataAlignRightStyle.setVerticalAlignment(VerticalAlignment.CENTER);
dataAlignRightStyle.setWrapText(true);
dataAlignRightStyle.setAlignment(HorizontalAlignment.RIGHT);
styles.put(GridStyleType.dataAlignRightStyle.name(), dataAlignRightStyle);
XSSFCellStyle dateStyle = (XSSFCellStyle) this.createBorderCellStyle(workbook, true);
CreationHelper helper = workbook.getCreationHelper();
dateStyle.setDataFormat(helper.createDataFormat().getFormat("m/d/yy h:mm"));
dateStyle.setFont(dataFont);
dateStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dateStyle.setFillForegroundColor(xssfContextBgColor);
dateStyle.setVerticalAlignment(VerticalAlignment.CENTER);
this.setCellStyleAligment(dateStyle, contextFontAlign);
styles.put(GridStyleType.dateStyle.name(), dateStyle);
return styles;
}
示例14: createPdcaItem
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
private int createPdcaItem(XSSFWorkbook wb, XSSFSheet sh, int row, XSSFCellStyle cellNormalStyle, List<PdcaItemVO> items, PdcaAuditVO audit) throws Exception {
XSSFColor fnColor = new XSSFColor( SimpleUtils.getColorRGB4POIColor("#000000") );
XSSFColor bgLabelColor = new XSSFColor( SimpleUtils.getColorRGB4POIColor("#F2F2F2") );
XSSFCellStyle cellLabelStyle = wb.createCellStyle();
cellLabelStyle.setFillForegroundColor( bgLabelColor );
cellLabelStyle.setFillPattern( FillPatternType.SOLID_FOREGROUND );
XSSFFont cellLabelFont = wb.createFont();
cellLabelFont.setBold(true);
cellLabelFont.setColor(fnColor);
cellLabelStyle.setFont(cellLabelFont);
cellLabelStyle.setBorderBottom(BorderStyle.THIN);
cellLabelStyle.setBorderTop(BorderStyle.THIN);
cellLabelStyle.setBorderRight(BorderStyle.THIN);
cellLabelStyle.setBorderLeft(BorderStyle.THIN);
cellLabelStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellLabelStyle.setAlignment(HorizontalAlignment.CENTER);
cellLabelStyle.setWrapText(true);
Map<String, String> pdcaTypeMap = PdcaType.getDataMap(false);
for (PdcaItemVO item : items) {
Row labelRow = sh.createRow(row);
Cell labelCell_6_1 = labelRow.createCell(0);
labelCell_6_1.setCellValue( pdcaTypeMap.get(item.getType()) );
labelCell_6_1.setCellStyle(cellLabelStyle);
Cell labelCell_6_2 = labelRow.createCell(1);
labelCell_6_2.setCellValue( item.getTitle() + ( !StringUtils.isBlank(item.getDescription()) ? "\n\n" + item.getDescription() : "" ) );
labelCell_6_2.setCellStyle(cellNormalStyle);
Cell labelCell_6_3 = labelRow.createCell(2);
labelCell_6_3.setCellValue( item.getEmployeeAppendNames() );
labelCell_6_3.setCellStyle(cellNormalStyle);
Cell labelCell_6_4 = labelRow.createCell(3);
labelCell_6_4.setCellValue( item.getStartDateDisplayValue() + " ~ " + item.getEndDateDisplayValue() );
labelCell_6_4.setCellStyle(cellNormalStyle);
Cell labelCell_6_5 = labelRow.createCell(4);
labelCell_6_5.setCellValue( (audit != null ? audit.getEmpId() : " ") );
labelCell_6_5.setCellStyle(cellNormalStyle);
Cell labelCell_6_6 = labelRow.createCell(5);
labelCell_6_6.setCellValue( (audit != null ? audit.getConfirmDateDisplayValue() : " ") );
labelCell_6_6.setCellStyle(cellNormalStyle);
row++;
}
return row;
}
示例15: testWriteExcelFileAttribute
import org.apache.poi.xssf.usermodel.XSSFCellStyle; //导入方法依赖的package包/类
/**
* [Flow #-3] 엑셀 파일 속성 수정 : 엑셀 파일의 속성(셀의 크기, Border의 속성, 셀의 색상, 정렬 등)을 수정함
*/
@Test
public void testWriteExcelFileAttribute() throws Exception {
try {
log.debug("testWriteExcelFileAttribute start....");
short rowheight = 40;
int columnwidth = 30;
StringBuffer sb = new StringBuffer();
sb.append(fileLocation).append("/").append("testWriteExcelFileAttribute.xlsx");
// delete file
if (EgovFileUtil.isExistsFile(sb.toString())) {
EgovFileUtil.delete(new File(sb.toString()));
log.debug("Delete file...." + sb.toString());
}
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet1 = wb.createSheet("new sheet");
wb.createSheet("second sheet");
// 셀의 크기
sheet1.setDefaultRowHeight(rowheight);
sheet1.setDefaultColumnWidth(columnwidth);
XSSFFont f2 = wb.createFont();
XSSFCellStyle cs = wb.createCellStyle();
cs = wb.createCellStyle();
cs.setFont( f2 );
cs.setWrapText( true );
// 정렬
cs.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
cs.setFillPattern(XSSFCellStyle.DIAMONDS); // 무늬 스타일
// 셀의 색상
cs.setFillForegroundColor(new XSSFColor(Color.BLUE).getIndexed()); // 무늬 색
cs.setFillBackgroundColor(new XSSFColor(Color.RED).getIndexed()); // 배경색
sheet1.setDefaultColumnStyle((short) 0, cs);
XSSFWorkbook tmp = excelService.createXSSFWorkbook(wb, sb.toString());
XSSFSheet sheetTmp1 = tmp.getSheetAt(0);
assertEquals(rowheight, sheetTmp1.getDefaultRowHeight());
assertEquals(columnwidth, sheetTmp1.getDefaultColumnWidth());
XSSFCellStyle cs1 = tmp.getCellStyleAt((short)(tmp.getNumCellStyles() - 1));
log.debug("getAlignment : " + cs1.getAlignment());
assertEquals(XSSFCellStyle.ALIGN_RIGHT, cs1.getAlignment());
log.debug("getFillPattern : " + cs1.getFillPattern());
assertEquals(XSSFCellStyle.DIAMONDS, cs1.getFillPattern());
log.debug("getFillForegroundColor : " + cs1.getFillForegroundColor());
log.debug("getFillBackgroundColor : " + cs1.getFillBackgroundColor());
assertEquals(new XSSFColor(Color.BLUE).getIndexed(), cs1.getFillForegroundColor());
assertEquals(new XSSFColor(Color.RED).getIndexed(), cs1.getFillBackgroundColor());
} catch (Exception e) {
log.error(e.toString());
throw new Exception(e);
} finally {
log.debug("testWriteExcelFileAttribute end....");
}
}