In your worksheet, your cell needs a style attribute (@s):
Using xml Syntax Highlighting
<c r="B2" s="1"/>
Parsed in 0.000 seconds, using
GeSHi 1.0.8.4
Per
http://webapp.docx4java.org/OnlineDemo/ ... L/c_1.htmls (Style Index): The index of this cell's style. Style records are stored in the Styles Part.
In the Styles part, in this example, you then have:
Using xml Syntax Highlighting
<fills count="3">
<fill>
<patternFill patternType="none"/>
</fill>
<fill>
<patternFill patternType="gray125"/>
</fill>
<fill>
<patternFill patternType="solid">
<fgColor theme="5"/>
<bgColor indexed="64"/>
</patternFill>
</fill>
</fills>
<cellXfs count="2">
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
<xf numFmtId="0" fontId="0" fillId="2" borderId="0" xfId="0" applyFill="1"/>
</cellXfs>
Parsed in 0.002 seconds, using
GeSHi 1.0.8.4
The index into cellXfs is zero-based, so here we are using fillId 2, which is the last of the fills.
To see whether your SpreadsheetMLPackage contains a org.docx4j.openpackaging.parts.SpreadsheetML.Styles part, invoke workbookPart.getStylesPart()
If your SpreadsheetMLPackage doesn't contain a Styles part, you'll need to instantiate one, then add it using workbookPart.addTargetPart(stylesPart). You'll need to create a CTStylesheet then call stylesPart.setContent(yourCTStylesheetObj)