Hi,
I have an existing table that I am appending rows to and I want the new
rows to have the same font, alignment, etc as the rows previous to the
additions but I'm finding that the new rows appear in the default
document font style.
He's a snippet of code I've used to try to manipulate the cell fonts.
Cell cellItem =
newRow.getCellByIndex(cellIndex++);
cellItem.setStringValue(cell);
if (firstRow != null) {
System.out.println("Cell=" +
firstRow.getCellByIndex(cellIndex - 1).getStringValue());
// System.out.println("Cell=" +
firstRow.getCellByIndex(cellIndex -
1).getHorizontalAlignmentType().getAlignmentString());
System.out.println("Cell=" +
firstRow.getCellByIndex(cellIndex - 1).getCellStyleName());
System.out.println("Cell=" +
firstRow.getCellByIndex(cellIndex - 1).getStyleHandler());
//
cellItem.setHorizontalAlignment(firstRow.getCellByIndex(cellIndex -
1).getHorizontalAlignmentType());
//cellItem.setFont(firstRow.getCellByIndex(cellIndex -1).getFont());
//cellItem.getFont().setSize(firstRow.getCellByIndex(cellIndex
-1).getFont().getSize() - 2);
cellItem.getStyleHandler().setFont(firstRow.getCellByIndex(cellIndex -
1).getStyleHandler().getFont(Document.ScriptType.WESTERN));
//
cellItem.setCellStyleName(firstRow.getCellByIndex(cellIndex -
1).getCellStyleName());
}
Except for the actual value of the cell, what prints out with the
System.out statements is not the actual font, font size, etc of the cell.
Is this a bug or am I not accessing and setting the values correctly?
I've been referencing this web page for trying to get my code to work
https://incubator.apache.org/odftoolkit/simple/document/cookbook/Style%20Handling.html#Advanced%20font%20handling
Thanks,
Andrew
P.S. This list is very quiet but I'm hoping someone is reading it from
time to time.