The following code creates a cell with the given style and text content.
The text content is used both for the office:string-value
attribute of the cell and for a child paragraph.
The null parameter to the OdfTextP constructor creates a
paragraph without a style name.
private OdfTableTableCell createCell(String cellStyle, String content) {
OdfTableTableCell cell = new OdfTableTableCell(contentDom);
OdfTextParagraph paragraph = new OdfTextParagraph(contentDom, null, content);
cell.setTableStyleNameAttribute(cellStyle);
cell.setOfficeStringValueAttribute(content);
cell.setOfficeValueTypeAttribute(
OfficeValueTypeAttribute.Value.STRING.toString());
cell.appendChild(paragraph);
return cell;
}
private String convertToOdfTime(String hourMinuteSecondTime) {
String[] timeParts = hourMinuteSecondTime.split(":");
String result = "PT" + timeParts[0] + "H" +
timeParts[1] + "M" + timeParts[2] + "S";
return result;
}