If you upload an example created in Excel to the webapp (linked above), you'll see something like:
Using xml Syntax Highlighting
<si>
<r>
<t xml:space="preserve">the
</t>
</r>
<r>
<rPr>
<sz val="11.0"/>
<color rgb="FFFF0000"/>
<rFont val="Calibri"/>
<family val="2"/>
<scheme val="minor"/>
</rPr>
<t>cat
</t>
</r>
<r>
<rPr>
<sz val="11.0"/>
<color theme="1"/>
<rFont val="Calibri"/>
<family val="2"/>
<scheme val="minor"/>
</rPr>
<t xml:space="preserve"> sat
</t>
</r>
</si>
Parsed in 0.004 seconds, using
GeSHi 1.0.8.4
in the shared strings table.
But as per the CreateSimpleSpreadsheet sample:
Using java Syntax Highlighting
/**
// Note: if you are trying to add characters, not a number,
// the easiest approach is to use inline strings (as opposed to the shared string table).
// See http://openxmldeveloper.org/blog/b/open ... heets.aspx
// and xlsx-java-f15/cells-with-character-values-t874.html
*/
private static Cell createCell
(String content
) {
Cell cell
= Context.
getsmlObjectFactory().
createCell();
CTXstringWhitespace ctx
= Context.
getsmlObjectFactory().
createCTXstringWhitespace();
ctx.
setValue(content
);
CTRst ctrst
= new CTRst
();
ctrst.
setT(ctx
);
cell.
setT(STCellType.
INLINE_STR);
cell.
setIs(ctrst
); // add ctrst as inline string
return cell
;
}
Parsed in 0.038 seconds, using
GeSHi 1.0.8.4
See further
http://webapp.docx4java.org/OnlineDemo/ ... ML/is.htmlUse t for text (as in the code above), or r for rich text.
A CTRElt in CTRst can have run properties, just like in the shared string table.
Untested code, generated by the webapp, then edited:
Using java Syntax Highlighting
import java.lang.Double;
import javax.xml.bind.JAXBElement;
import org.xlsx4j.sml.CTColor;
import org.xlsx4j.sml.CTRElt;
import org.xlsx4j.sml.CTRPrElt;
import org.xlsx4j.sml.CTXstringWhitespace;
public class Foo
{
public CTRElt createIt
() {
org.
xlsx4j.
sml.
ObjectFactory smlObjectFactory
= new org.
xlsx4j.
sml.
ObjectFactory();
CTRElt relt
= smlObjectFactory.
createCTRElt();
// Create object for rPr
CTRPrElt rprelt
= smlObjectFactory.
createCTRPrElt();
relt.
setRPr(rprelt
);
// Create object for color (wrapped in JAXBElement)
CTColor color
= smlObjectFactory.
createCTColor();
JAXBElement
<org.
xlsx4j.
sml.
CTColor> colorWrapped
= smlObjectFactory.
createCTRPrEltColor(color
);
rprelt.
getRFontOrCharsetOrFamily().
add( colorWrapped
);
color.
setRgb(value
); // byte[] value
// Create object for t
CTXstringWhitespace xstringwhitespace
= smlObjectFactory.
createCTXstringWhitespace();
relt.
setT(xstringwhitespace
);
xstringwhitespace.
setValue( "cat");
return relt
;
}
}
Parsed in 0.025 seconds, using
GeSHi 1.0.8.4
or
Using java Syntax Highlighting
String openXML
= "<r>
+ "<rPr
>
+ "<color rgb=\"FFFF0000\"/>"
+"</rPr>"
+ "<t>cat</t>"
+"</r>";
CTRElt relt
= (CTRElt
)XmlUtils.
unmarshalString(openXML,
Context.
jcSML);
Parsed in 0.015 seconds, using
GeSHi 1.0.8.4