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)
CellStyle
cell
- 单元格cellStyle
- 被复制的样式CellStyle
public static org.apache.poi.ss.usermodel.CellStyle cloneCellStyle(org.apache.poi.ss.usermodel.Workbook workbook, org.apache.poi.ss.usermodel.CellStyle cellStyle)
CellStyle
workbook
- 工作簿cellStyle
- 被复制的样式CellStyle
public 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
- CellStyle
halign
- 横向位置valign
- 纵向位置CellStyle
public 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
- CellStyle
borderSize
- 边框粗细BorderStyle
枚举colorIndex
- 颜色的short值CellStyle
public 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
- CellStyle
color
- 背景颜色fillPattern
- 填充方式 FillPatternType
枚举CellStyle
public 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
- CellStyle
color
- 背景颜色fillPattern
- 填充方式 FillPatternType
枚举CellStyle
public static org.apache.poi.ss.usermodel.Font createFont(org.apache.poi.ss.usermodel.Workbook workbook, short color, short fontSize, String fontName)
workbook
- Workbook
color
- 字体颜色fontSize
- 字体大小fontName
- 字体名称,可以为null使用默认字体Font
public static org.apache.poi.ss.usermodel.Font setFontStyle(org.apache.poi.ss.usermodel.Font font, short color, short fontSize, String fontName)
font
- 字体Font
color
- 字体颜色fontSize
- 字体大小fontName
- 字体名称,可以为null使用默认字体Font
public static org.apache.poi.ss.usermodel.CellStyle createCellStyle(org.apache.poi.ss.usermodel.Workbook workbook)
workbook
- Workbook
工作簿CellStyle
Workbook.createCellStyle()
public static org.apache.poi.ss.usermodel.CellStyle createDefaultCellStyle(org.apache.poi.ss.usermodel.Workbook workbook)
1. 文字上下左右居中 2. 细边框,黑色
workbook
- Workbook
工作簿CellStyle
public static org.apache.poi.ss.usermodel.CellStyle createHeadCellStyle(org.apache.poi.ss.usermodel.Workbook workbook)
workbook
- Workbook
工作簿CellStyle
public static boolean isNullOrDefaultStyle(org.apache.poi.ss.usermodel.Workbook workbook, org.apache.poi.ss.usermodel.CellStyle style)
workbook.getCellStyleAt(0)
workbook
- 工作簿style
- 被检查的样式Copyright © 2024. All rights reserved.