}
}
@Test
public void testCellSizeOptimal() {
Font font1Base = new Font("Arial", FontStyle.REGULAR, 6, Color.GREEN, TextLinePosition.REGULAR);
Font font2Base = new Font("Times New Roman", FontStyle.REGULAR, 13, Color.RED, TextLinePosition.REGULAR);
Font font3Base = new Font("SimSun", FontStyle.REGULAR, 17, Color.BLUE, TextLinePosition.REGULAR);
try {
final SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
final Table table = doc.addTable();
final String contentStr = "This is a long text content.";
// basically the default font is of Arial type, so assume the default family
final String nfFamilyName = "Arial";
if (isFontAvailable(nfFamilyName)) {
checkCellWidth(table.getCellByPosition(0, 0), null, 44.0977, contentStr);
}
if (isFontAvailable(font1Base.getFamilyName())) {
checkCellWidth(table.getCellByPosition(1, 1), font1Base, 24.3424, contentStr);
}
if (isFontAvailable(font2Base.getFamilyName())) {
checkCellWidth(table.getCellByPosition(2, 2), font2Base, 49.7414, contentStr);
}
if (isFontAvailable(font3Base.getFamilyName())) {
checkCellWidth(table.getCellByPosition(3, 3), font3Base, 88.899, contentStr);
}
doc.save(ResourceUtilities.newTestOutputFile("testCellSizeOptimal.ods"));
} catch (Exception e) {
Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, null, e);