public class StyleUtil extends Object
| Constructor and Description | 
|---|
| StyleUtil() | 
| Modifier and Type | Method and Description | 
|---|---|
| static org.apache.poi.ss.usermodel.CellStyle | cloneCellStyle(org.apache.poi.ss.usermodel.Cell cell,
              org.apache.poi.ss.usermodel.CellStyle cellStyle)克隆新的 CellStyle | 
| static org.apache.poi.ss.usermodel.CellStyle | cloneCellStyle(org.apache.poi.ss.usermodel.Workbook workbook,
              org.apache.poi.ss.usermodel.CellStyle cellStyle)克隆新的 CellStyle | 
| static org.apache.poi.ss.usermodel.CellStyle | createCellStyle(org.apache.poi.ss.usermodel.Workbook workbook)创建单元格样式 | 
| static org.apache.poi.ss.usermodel.CellStyle | createDefaultCellStyle(org.apache.poi.ss.usermodel.Workbook workbook)创建默认普通单元格样式
 
 1. | 
| static org.apache.poi.ss.usermodel.Font | createFont(org.apache.poi.ss.usermodel.Workbook workbook,
          short color,
          short fontSize,
          String fontName)创建字体 | 
| static org.apache.poi.ss.usermodel.CellStyle | createHeadCellStyle(org.apache.poi.ss.usermodel.Workbook workbook)创建默认头部样式 | 
| static Short | getFormat(org.apache.poi.ss.usermodel.Workbook workbook,
         String format)创建数据格式并获取格式 | 
| static boolean | isNullOrDefaultStyle(org.apache.poi.ss.usermodel.Workbook workbook,
                    org.apache.poi.ss.usermodel.CellStyle style)给定样式是否为null(无样式)或默认样式,默认样式为 workbook.getCellStyleAt(0) | 
| static org.apache.poi.ss.usermodel.CellStyle | setAlign(org.apache.poi.ss.usermodel.CellStyle cellStyle,
        org.apache.poi.ss.usermodel.HorizontalAlignment halign,
        org.apache.poi.ss.usermodel.VerticalAlignment valign)设置cell文本对齐样式 | 
| static org.apache.poi.ss.usermodel.CellStyle | setBorder(org.apache.poi.ss.usermodel.CellStyle cellStyle,
         org.apache.poi.ss.usermodel.BorderStyle borderSize,
         org.apache.poi.ss.usermodel.IndexedColors colorIndex)设置cell的四个边框粗细和颜色 | 
| static org.apache.poi.ss.usermodel.CellStyle | setColor(org.apache.poi.ss.usermodel.CellStyle cellStyle,
        org.apache.poi.ss.usermodel.IndexedColors color,
        org.apache.poi.ss.usermodel.FillPatternType fillPattern)给cell设置颜色 | 
| static org.apache.poi.ss.usermodel.CellStyle | setColor(org.apache.poi.ss.usermodel.CellStyle cellStyle,
        short color,
        org.apache.poi.ss.usermodel.FillPatternType fillPattern)给cell设置颜色 | 
| static org.apache.poi.ss.usermodel.Font | setFontStyle(org.apache.poi.ss.usermodel.Font font,
            short color,
            short fontSize,
            String fontName)设置字体样式 | 
public static org.apache.poi.ss.usermodel.CellStyle cloneCellStyle(org.apache.poi.ss.usermodel.Cell cell,
                                                                   org.apache.poi.ss.usermodel.CellStyle cellStyle)
CellStylecell - 单元格cellStyle - 被复制的样式CellStylepublic static org.apache.poi.ss.usermodel.CellStyle cloneCellStyle(org.apache.poi.ss.usermodel.Workbook workbook,
                                                                   org.apache.poi.ss.usermodel.CellStyle cellStyle)
CellStyleworkbook - 工作簿cellStyle - 被复制的样式CellStylepublic static org.apache.poi.ss.usermodel.CellStyle setAlign(org.apache.poi.ss.usermodel.CellStyle cellStyle,
                                                             org.apache.poi.ss.usermodel.HorizontalAlignment halign,
                                                             org.apache.poi.ss.usermodel.VerticalAlignment valign)
cellStyle - CellStylehalign - 横向位置valign - 纵向位置CellStylepublic static org.apache.poi.ss.usermodel.CellStyle setBorder(org.apache.poi.ss.usermodel.CellStyle cellStyle,
                                                              org.apache.poi.ss.usermodel.BorderStyle borderSize,
                                                              org.apache.poi.ss.usermodel.IndexedColors colorIndex)
cellStyle - CellStyleborderSize - 边框粗细BorderStyle枚举colorIndex - 颜色的short值CellStylepublic static org.apache.poi.ss.usermodel.CellStyle setColor(org.apache.poi.ss.usermodel.CellStyle cellStyle,
                                                             org.apache.poi.ss.usermodel.IndexedColors color,
                                                             org.apache.poi.ss.usermodel.FillPatternType fillPattern)
cellStyle - CellStylecolor - 背景颜色fillPattern - 填充方式 FillPatternType枚举CellStylepublic static org.apache.poi.ss.usermodel.CellStyle setColor(org.apache.poi.ss.usermodel.CellStyle cellStyle,
                                                             short color,
                                                             org.apache.poi.ss.usermodel.FillPatternType fillPattern)
cellStyle - CellStylecolor - 背景颜色fillPattern - 填充方式 FillPatternType枚举CellStylepublic static org.apache.poi.ss.usermodel.Font createFont(org.apache.poi.ss.usermodel.Workbook workbook,
                                                          short color,
                                                          short fontSize,
                                                          String fontName)
workbook - Workbookcolor - 字体颜色fontSize - 字体大小fontName - 字体名称,可以为null使用默认字体Fontpublic static org.apache.poi.ss.usermodel.Font setFontStyle(org.apache.poi.ss.usermodel.Font font,
                                                            short color,
                                                            short fontSize,
                                                            String fontName)
font - 字体Fontcolor - 字体颜色fontSize - 字体大小fontName - 字体名称,可以为null使用默认字体Fontpublic static org.apache.poi.ss.usermodel.CellStyle createCellStyle(org.apache.poi.ss.usermodel.Workbook workbook)
workbook - Workbook 工作簿CellStyleWorkbook.createCellStyle()public static org.apache.poi.ss.usermodel.CellStyle createDefaultCellStyle(org.apache.poi.ss.usermodel.Workbook workbook)
1. 文字上下左右居中 2. 细边框,黑色
workbook - Workbook 工作簿CellStylepublic static org.apache.poi.ss.usermodel.CellStyle createHeadCellStyle(org.apache.poi.ss.usermodel.Workbook workbook)
workbook - Workbook 工作簿CellStylepublic static boolean isNullOrDefaultStyle(org.apache.poi.ss.usermodel.Workbook workbook,
                                           org.apache.poi.ss.usermodel.CellStyle style)
workbook.getCellStyleAt(0)workbook - 工作簿style - 被检查的样式Copyright © 2025. All rights reserved.