public class StylesTable extends POIXMLDocumentPart implements Styles
POIXMLDocumentPart.RelationPart
Modifier and Type | Field and Description |
---|---|
static int |
FIRST_CUSTOM_STYLE_ID
The first style id available for use as a custom style
(第一个可用作自定义样式的样式 ID)
|
Constructor and Description |
---|
StylesTable()
Create a new, empty StylesTable
|
StylesTable(PackagePart part) |
Modifier and Type | Method and Description |
---|---|
int |
_getDXfsSize() |
int |
_getStyleXfsSize()
For unit testing only
(仅用于单元测试)
|
protected void |
commit()
Save the content in the underlying package part.
(将内容保存在底层包部分中。)
|
XSSFCellStyle |
createCellStyle()
Create a cell style in this style table.
(在此样式表中创建单元格样式。)
|
void |
ensureThemesTable()
If there isn't currently a
ThemesTable for the current Workbook, then creates one and sets it up.
(如果当前工作簿当前没有 ThemesTable,则创建一个并设置它。)
|
XSSFFont |
findFont(boolean bold, Color color, short fontHeight, java.lang.String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
Finds a font that matches the one with the supplied attributes, where color is the actual Color-value, not the indexed color
(查找与提供的属性匹配的字体,其中颜色是实际的颜色值,而不是索引颜色)
|
XSSFFont |
findFont(boolean bold, short color, short fontHeight, java.lang.String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
Finds a font that matches the one with the supplied attributes, where color is the indexed-value, not the actual color.
(查找与提供的属性匹配的字体,其中颜色是索引值,而不是实际颜色。)
|
XSSFCellBorder |
getBorderAt(int idx) |
java.util.List<XSSFCellBorder> |
getBorders() |
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf |
getCellStyleXfAt(int idx) |
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf |
getCellXfAt(int idx) |
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet |
getCTStylesheet()
For unit testing only!
(仅用于单元测试!)
|
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxf |
getDxfAt(int idx) |
TableStyle |
getExplicitTableStyle(java.lang.String name)
NOTE: this only returns explicitly defined styles
(注意:这只返回明确定义的样式)
|
java.util.Set<java.lang.String> |
getExplicitTableStyleNames() |
XSSFCellFill |
getFillAt(int idx) |
java.util.List<XSSFCellFill> |
getFills() |
XSSFFont |
getFontAt(int idx) |
java.util.List<XSSFFont> |
getFonts() |
IndexedColorMap |
getIndexedColors() |
int |
getMaxNumberOfDataFormats()
Get the upper limit on the number of data formats that has been set for the style table.
(获取已为样式表设置的数据格式数量上限。)
|
java.lang.String |
getNumberFormatAt(short fmtId)
Get number format string given its id
(获取给定其 id 的数字格式字符串)
|
java.util.Map<java.lang.Short,java.lang.String> |
getNumberFormats() |
int |
getNumCellStyles()
get the size of cell styles
(获取单元格样式的大小)
|
int |
getNumDataFormats() |
XSSFCellStyle |
getStyleAt(int idx) |
TableStyle |
getTableStyle(java.lang.String name) |
ThemesTable |
getTheme()
Get the current Workbook's theme table, or null if the Workbook lacks any themes.
(获取当前 Workbook 的主题表,如果 Workbook 缺少任何主题,则为 null。)
|
int |
putBorder(XSSFCellBorder border)
Adds a border to the border style table if it isn't already in the style table Does nothing if border is already in borders style table
(如果边框样式表中还没有边框,则将边框添加到边框样式表中 如果边框已经在边框样式表中,则不执行任何操作)
|
int |
putCellStyleXf(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf cellStyleXf)
Adds a cell style to the styles table.
(将单元格样式添加到样式表。)
|
int |
putCellXf(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf cellXf)
Adds a cell to the styles table.
(向样式表中添加一个单元格。)
|
int |
putDxf(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxf dxf)
Adds a Dxf to the style table Does not check for duplicates.
(向样式表添加 Dxf 不检查重复项。)
|
int |
putFill(XSSFCellFill fill)
Adds a fill to the fill style table if it isn't already in the style table Does nothing if fill is already in fill style table
(如果样式表中没有填充样式表,则将填充添加到样式表中 如果填充样式表中已有填充,则不执行任何操作)
|
int |
putFont(XSSFFont font)
Records the given font in the font table.
(在字体表中记录给定的字体。)
|
int |
putFont(XSSFFont font, boolean forceRegistration)
Records the given font in the font table.
(在字体表中记录给定的字体。)
|
void |
putNumberFormat(short index, java.lang.String fmt)
Add a number format with a specific ID into the numberFormats map.
(将具有特定 ID 的数字格式添加到 numberFormats 映射中。)
|
int |
putNumberFormat(java.lang.String fmt)
Puts
fmt in the numberFormats map if the format is not already in the the number format style table.
(如果格式不在数字格式样式表中,则将 fmt 放入 numberFormats 映射中。)
|
int |
putStyle(XSSFCellStyle style) |
void |
readFrom(java.io.InputStream is)
Read this shared styles table from an XML file.
(从 XML 文件中读取此共享样式表。)
|
boolean |
removeNumberFormat(short index)
Remove a number format from the style table if it exists.
(如果存在,请从样式表中删除数字格式。)
|
boolean |
removeNumberFormat(java.lang.String fmt)
Remove a number format from the style table if it exists All cell styles with this number format will be modified to use the default number format
(从样式表中删除数字格式(如果存在) 所有具有此数字格式的单元格样式将被修改为使用默认数字格式)
|
protected void |
replaceCellStyleXfAt(int idx, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf cellStyleXf) |
void |
replaceCellXfAt(int idx, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf cellXf) |
void |
setMaxNumberOfDataFormats(int num)
Changes the maximum number of data formats that may be in a style table
(更改样式表中可能存在的最大数据格式数)
|
void |
setTheme(ThemesTable theme) |
void |
setWorkbook(XSSFWorkbook wb) |
void |
writeTo(java.io.OutputStream out)
Write this table out as XML.
(将此表写为 XML。)
|
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toString
public static final int FIRST_CUSTOM_STYLE_ID
public StylesTable()
public StylesTable(PackagePart part) throws java.io.IOException
java.io.IOException
(java.io.IOException)
public void setMaxNumberOfDataFormats(int num)
num
- the upper limit on number of data formats in the styles table when adding new data formats
(num - 添加新数据格式时样式表中数据格式数量的上限)
java.lang.IllegalArgumentException
- if
num
< 0
(java.lang.IllegalArgumentException - 如果 num < 0)
java.lang.IllegalStateException
- if
num
< current number of data formats in the style table. Data formats must be explicitly removed before the limit can be decreased.
(java.lang.IllegalStateException - 如果 num < 样式表中的当前数据格式数。必须先明确删除数据格式,然后才能减少限制。)
public int getMaxNumberOfDataFormats()
getNumDataFormats()
.
(获取已为样式表设置的数据格式数量上限。要获取当前使用的数据格式数量,请使用 getNumDataFormats()。)
public void setWorkbook(XSSFWorkbook wb)
public ThemesTable getTheme()
Use ensureThemesTable()
to have a themes table created if needed
public void setTheme(ThemesTable theme)
public void ensureThemesTable()
ThemesTable
for the current Workbook, then creates one and sets it up. After this, calls to
getTheme()
won't give null
(如果当前工作簿当前没有 ThemesTable,则创建一个并设置它。在此之后,调用 getTheme() 不会给出 null)
public void readFrom(java.io.InputStream is) throws java.io.IOException
is
- The input stream containing the XML document.
(is - 包含 XML 文档的输入流。)
java.io.IOException
- if an error occurs while reading.
(java.io.IOException - 如果读取时发生错误。)
public java.lang.String getNumberFormatAt(short fmtId)
getNumberFormatAt
in interface
Styles
(接口 Styles 中的 getNumberFormatAt)
fmtId
- number format id
(fmtId - 数字格式 ID)
public int putNumberFormat(java.lang.String fmt)
fmt
in the numberFormats map if the format is not already in the the number format style table. Does nothing if
fmt
is already in number format style table.
(如果格式不在数字格式样式表中,则将 fmt 放入 numberFormats 映射中。如果 fmt 已经在数字格式样式表中,则不执行任何操作。)
putNumberFormat
in interface
Styles
(接口样式中的 putNumberFormat)
fmt
- the number format to add to number format style table
(fmt - 添加到数字格式样式表的数字格式)
fmt
in the number format style table
(数字格式样式表中 fmt 的索引)
java.lang.IllegalStateException
- if adding the number format to the styles table would exceed the
MAXIMUM_NUMBER_OF_DATA_FORMATS
allowed.
(java.lang.IllegalStateException - 如果将数字格式添加到样式表将超过允许的 MAXIMUM_NUMBER_OF_DATA_FORMATS。)
public void putNumberFormat(short index, java.lang.String fmt)
fmt
This may be used to override built-in number formats.
(将具有特定 ID 的数字格式添加到 numberFormats 映射中。如果已存在具有相同 ID 的格式,则使用 fmt 覆盖格式代码这可用于覆盖内置数字格式。)
putNumberFormat
in interface
Styles
(接口样式中的 putNumberFormat)
index
- the number format ID
(index - 数字格式 ID)
fmt
- the number format code
(fmt - 数字格式代码)
public boolean removeNumberFormat(short index)
removeNumberFormat
in interface
Styles
(界面样式中的 removeNumberFormat)
index
- the number format id to remove
(index - 要删除的数字格式 ID)
public boolean removeNumberFormat(java.lang.String fmt)
removeNumberFormat
in interface
Styles
(界面样式中的 removeNumberFormat)
fmt
- the number format to remove
(fmt - 要删除的数字格式)
public XSSFFont getFontAt(int idx)
public int putFont(XSSFFont font, boolean forceRegistration)
XSSFFont.registerTo(StylesTable)
(在字体表中记录给定的字体。如果此字体与另一个字体匹配,将重新使用现有字体索引,除非请求强制注册。这允许人们创建几种字体,然后在以后对其进行自定义。注意 - 最终用户可能想要调用 XSSFFont.registerTo(StylesTable))
public int putFont(XSSFFont font)
Styles
public XSSFCellStyle getStyleAt(int idx)
getStyleAt
in interface
Styles
(接口样式中的getStyleAt)
idx
- style index
(idx - 风格索引)
public int putStyle(XSSFCellStyle style)
public XSSFCellBorder getBorderAt(int idx)
getBorderAt
in interface
Styles
(接口样式中的 getBorderAt)
public int putBorder(XSSFCellBorder border)
public XSSFCellFill getFillAt(int idx)
public java.util.List<XSSFCellBorder> getBorders()
public java.util.List<XSSFCellFill> getFills()
public java.util.List<XSSFFont> getFonts()
public java.util.Map<java.lang.Short,java.lang.String> getNumberFormats()
public int putFill(XSSFCellFill fill)
@Internal public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf getCellXfAt(int idx)
@Internal public int putCellXf(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf cellXf)
cellXf
- the cell to add to the styles table
(cellXf - 添加到样式表的单元格)
@Internal public void replaceCellXfAt(int idx, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf cellXf)
@Internal public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf getCellStyleXfAt(int idx)
@Internal public int putCellStyleXf(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf cellStyleXf)
cellStyleXf
- the cell style to add to the styles table
(cellStyleXf - 添加到样式表的单元格样式)
@Internal protected void replaceCellStyleXfAt(int idx, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf cellStyleXf)
public int getNumCellStyles()
getNumCellStyles
in interface
Styles
(接口 Styles 中的 getNumCellStyles)
public int getNumDataFormats()
getNumDataFormats
in interface
Styles
(接口样式中的 getNumDataFormats)
@Internal public int _getStyleXfsSize()
@Internal public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet getCTStylesheet()
@Internal public int _getDXfsSize()
public void writeTo(java.io.OutputStream out) throws java.io.IOException
out
- The stream to write to.
(out - 要写入的流。)
java.io.IOException
- if an error occurs while writing.
(java.io.IOException - 如果写入时发生错误。)
protected void commit() throws java.io.IOException
POIXMLDocumentPart
Sub-classes should override and add logic to marshal the "model" into Ooxml4J.
For example, the code saving a generic XML entry may look as follows:
protected void commit() throws IOException { PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); XmlObject bean = getXmlBean(); //the "model" which holds changes in memory bean.save(out, DEFAULT_XML_OPTIONS); out.close(); }(将内容保存在底层包部分中。默认实现是空的,这意味着包部分保持不变。子类应覆盖并添加逻辑以将“模型”编组到 Ooxml4J。例如,保存通用 XML 条目的代码可能如下所示: protected void commit() throws IOException { PackagePart part = getPackagePart();输出流输出 = part.getOutputStream(); XmlObject bean = getXmlBean(); //保存内存变化的“模型” bean.save(out, DEFAULT_XML_OPTIONS); out.close(); })
commit
in class
POIXMLDocumentPart
java.io.IOException
- a subclass may throw an IOException if the changes can't be committed
(java.io.IOException - 如果无法提交更改,子类可能会抛出 IOException)
@Internal public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxf getDxfAt(int idx)
@Internal public int putDxf(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxf dxf)
dxf
- the Dxf to add
(dxf - 要添加的 Dxf)
public TableStyle getExplicitTableStyle(java.lang.String name)
name
- of the table style
(名称 - 表格样式)
public java.util.Set<java.lang.String> getExplicitTableStyleNames()
public TableStyle getTableStyle(java.lang.String name)
name
- of the table style
(名称 - 表格样式)
public XSSFCellStyle createCellStyle()
XSSFWorkbook.createCellStyle()
rather than working with the styles table directly.
(在此样式表中创建单元格样式。注意 - 最终用户可能希望调用 XSSFWorkbook.createCellStyle() 而不是直接使用样式表。)
java.lang.IllegalStateException
- if the maximum number of cell styles has been reached.
(java.lang.IllegalStateException - 如果已达到最大单元格样式数。)
public XSSFFont findFont(boolean bold, short color, short fontHeight, java.lang.String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
public XSSFFont findFont(boolean bold, Color color, short fontHeight, java.lang.String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
public IndexedColorMap getIndexedColors()
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.