Bug 55386: Fix handling of bold formatting in example application 'ToHtml'

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1668486 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2015-03-22 21:48:48 +00:00
parent dd875c9c04
commit 7801cb1f54
1 changed files with 7 additions and 3 deletions

View File

@ -289,7 +289,7 @@ public class ToHtml {
private void fontStyle(CellStyle style) { private void fontStyle(CellStyle style) {
Font font = wb.getFontAt(style.getFontIndex()); Font font = wb.getFontAt(style.getFontIndex());
if (font.getBoldweight() >= HSSFFont.BOLDWEIGHT_NORMAL) if (font.getBoldweight() >= HSSFFont.BOLDWEIGHT_BOLD)
out.format(" font-weight: bold;%n"); out.format(" font-weight: bold;%n");
if (font.getItalic()) if (font.getItalic())
out.format(" font-style: italic;%n"); out.format(" font-style: italic;%n");
@ -309,8 +309,12 @@ public class ToHtml {
style = wb.getCellStyleAt((short) 0); style = wb.getCellStyleAt((short) 0);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
Formatter fmt = new Formatter(sb); Formatter fmt = new Formatter(sb);
try {
fmt.format("style_%02x", style.getIndex()); fmt.format("style_%02x", style.getIndex());
return fmt.toString(); return fmt.toString();
} finally {
fmt.close();
}
} }
private <K> void styleOut(String attr, K key, Map<K, String> mapping) { private <K> void styleOut(String attr, K key, Map<K, String> mapping) {