public class StyleSet extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
protected org.apache.poi.ss.usermodel.CellStyle |
cellStyle
默认样式
|
protected org.apache.poi.ss.usermodel.CellStyle |
cellStyleForDate
默认日期样式
|
protected org.apache.poi.ss.usermodel.CellStyle |
cellStyleForHyperlink
默认链接样式
|
protected org.apache.poi.ss.usermodel.CellStyle |
cellStyleForNumber
默认数字样式
|
protected org.apache.poi.ss.usermodel.CellStyle |
headCellStyle
标题样式
|
Constructor and Description |
---|
StyleSet(org.apache.poi.ss.usermodel.Workbook workbook)
构造
|
Modifier and Type | Method and Description |
---|---|
org.apache.poi.ss.usermodel.CellStyle |
getCellStyle()
获取常规单元格样式,获取后可以定义整体头部样式
|
org.apache.poi.ss.usermodel.CellStyle |
getCellStyleForDate()
获取日期单元格样式,获取后可以定义整体日期样式
|
org.apache.poi.ss.usermodel.CellStyle |
getCellStyleForHyperlink()
获取链接单元格样式,获取后可以定义整体链接样式
|
org.apache.poi.ss.usermodel.CellStyle |
getCellStyleForNumber()
获取数字(带小数点)单元格样式,获取后可以定义整体数字样式
|
org.apache.poi.ss.usermodel.CellStyle |
getHeadCellStyle()
获取头部样式,获取后可以定义整体头部样式
|
org.apache.poi.ss.usermodel.CellStyle |
getStyleByValueType(Object value,
boolean isHeader)
获取值对应的公共单元格样式
|
StyleSet |
setAlign(org.apache.poi.ss.usermodel.HorizontalAlignment halign,
org.apache.poi.ss.usermodel.VerticalAlignment valign)
设置cell文本对齐样式
|
StyleSet |
setBackgroundColor(org.apache.poi.ss.usermodel.IndexedColors backgroundColor,
boolean withHeadCell)
设置单元格背景样式
|
StyleSet |
setBorder(org.apache.poi.ss.usermodel.BorderStyle borderSize,
org.apache.poi.ss.usermodel.IndexedColors colorIndex)
定义所有单元格的边框类型
|
StyleSet |
setFont(org.apache.poi.ss.usermodel.Font font,
boolean ignoreHead)
设置全局字体
|
StyleSet |
setFont(short color,
short fontSize,
String fontName,
boolean ignoreHead)
设置全局字体
|
StyleSet |
setWrapText()
设置单元格文本自动换行
|
protected final org.apache.poi.ss.usermodel.CellStyle headCellStyle
protected final org.apache.poi.ss.usermodel.CellStyle cellStyle
protected final org.apache.poi.ss.usermodel.CellStyle cellStyleForNumber
protected final org.apache.poi.ss.usermodel.CellStyle cellStyleForDate
protected final org.apache.poi.ss.usermodel.CellStyle cellStyleForHyperlink
public StyleSet(org.apache.poi.ss.usermodel.Workbook workbook)
workbook
- 工作簿public org.apache.poi.ss.usermodel.CellStyle getHeadCellStyle()
public org.apache.poi.ss.usermodel.CellStyle getCellStyle()
public org.apache.poi.ss.usermodel.CellStyle getCellStyleForNumber()
public org.apache.poi.ss.usermodel.CellStyle getCellStyleForDate()
public org.apache.poi.ss.usermodel.CellStyle getCellStyleForHyperlink()
public StyleSet setBorder(org.apache.poi.ss.usermodel.BorderStyle borderSize, org.apache.poi.ss.usermodel.IndexedColors colorIndex)
borderSize
- 边框粗细BorderStyle
枚举colorIndex
- 颜色的short值public StyleSet setAlign(org.apache.poi.ss.usermodel.HorizontalAlignment halign, org.apache.poi.ss.usermodel.VerticalAlignment valign)
halign
- 横向位置valign
- 纵向位置public StyleSet setBackgroundColor(org.apache.poi.ss.usermodel.IndexedColors backgroundColor, boolean withHeadCell)
backgroundColor
- 背景色withHeadCell
- 是否也定义头部样式public StyleSet setFont(short color, short fontSize, String fontName, boolean ignoreHead)
color
- 字体颜色fontSize
- 字体大小,-1表示默认大小fontName
- 字体名,null表示默认字体ignoreHead
- 是否跳过头部样式public StyleSet setFont(org.apache.poi.ss.usermodel.Font font, boolean ignoreHead)
font
- 字体,可以通过StyleUtil.createFont(Workbook, short, short, String)
创建ignoreHead
- 是否跳过头部样式public StyleSet setWrapText()
public org.apache.poi.ss.usermodel.CellStyle getStyleByValueType(Object value, boolean isHeader)
value
- 值isHeader
- 是否为标题单元格Copyright © 2024. All rights reserved.