gpt4 book ai didi

java - CTCol 对象有什么作用以及它在 POI 中代表什么?

转载 作者:行者123 更新时间:2023-12-02 11:03:41 27 4
gpt4 key购买 nike

我是 POI 新手。

我想为工作表中的所有单元格设置字体。

所以,我发现我可以用下面的代码来实现它:

CTCol cTCol = ((XSSFSheet) sheet).getCTWorksheet().getColsArray(0).addNewCol();
cTCol.setMin(1);
cTCol.setMax(16384);
cTCol.setWidth(12.7109375);
cTCol.setStyle(cellStyle.getIndex());

但我不知道 CTCol 对象是如何工作的。

所以想请教一下:

  1. 它是如何工作的。

  2. 此外,我想知道 CT 在 CTCol 中代表什么。

有谁愿意解释一下吗?

提前谢谢您!

祝你度过愉快的一天:D

最佳答案

apache poiXSSFWorkbookOffice Open XML 中的一个 Excel 工作簿格式。

Office Open XML (also informally known as OOXML or Microsoft Open XML (MOX)[3]) is a zipped, XML-based file format developed by Microsoft[4] for representing spreadsheets, charts, presentations and word processing documents. The format was initially standardized by Ecma (as ECMA-376), and by the ISO and IEC (as ISO/IEC 29500) in later versions.

为了对此进行编程,apache poihigh level classes基于 ooxml-schemas-1.3.jar 的低级类(class)。其中一些还随 poi-ooxml-schemas-version-yyyymmdd.jar 一起提供。

不幸的是,不再有任何关于 Javaooxml-schemas 类的文档。以前至少有第三方文档可用。但目前它们均不可用。因此,获取此文档的唯一可能性是获取 ooxml-schemas-1.3-sources.jar然后使用这些源执行 javadoc

背景:ooxml-schemas 是转换为 Java 类的 Office Open XMLXSD 架构定义。该架构定义了xsd:complexType。因此,ooxml-schemas 类名中的 CT 代表 ComplexType。

有关 XML 架构定义,请参阅 Ecma Office Open XML File Formats Standard - Final draft - 9th of October 2006 .

名为 CT_Col 的复杂类型定义了 SpreadsheetML 的列设置,这在 3.3.1.12 col(列宽和格式) 章节中进行了描述。 Office Open XML Ecma TC45 Final Draft Part 4: Markup Language Reference .

以下 XML 架构片段定义此元素的内容:

<complexType name="CT_Col">
<attribute name="min" type="xsd:unsignedInt" use="required"/>
<attribute name="max" type="xsd:unsignedInt" use="required"/>
<attribute name="width" type="xsd:double" use="optional"/>
<attribute name="style" type="xsd:unsignedInt" use="optional" default="0"/>
<attribute name="hidden" type="xsd:boolean" use="optional" default="false"/>
<attribute name="bestFit" type="xsd:boolean" use="optional" default="false"/>
<attribute name="customWidth" type="xsd:boolean" use="optional" default="false"/>
<attribute name="phonetic" type="xsd:boolean" use="optional" default="false"/>
<attribute name="outlineLevel" type="xsd:unsignedByte" use="optional" default="0"/>
<attribute name="collapsed" type="xsd:boolean" use="optional" default="false"/>
</complexType>

关于java - CTCol 对象有什么作用以及它在 POI 中代表什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51145150/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com