Bug 39389 - Excel doesn't display extended ASCII WingDings.
Summary: Excel doesn't display extended ASCII WingDings.
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2006-04-24 10:01 UTC by Yegor Kozlov
Modified: 2007-01-12 03:54 UTC (History)
0 users

test case (2.34 KB, application/octet-stream)
2006-04-24 10:03 UTC, Yegor Kozlov
sample workbook with extended ascii wingdings (4.00 KB, application/vnd.ms-excel)
2006-04-24 13:03 UTC, Yegor Kozlov
patch for HSSFFont (1.40 KB, patch)
2006-04-25 09:53 UTC, Yegor Kozlov
Details | Diff
HSSFFont which can modify charset (8.86 KB, application/octet-stream)
2006-04-25 09:54 UTC, Yegor Kozlov

Note You need to log in before you can comment on or make changes to this bug.
Description Yegor Kozlov 2006-04-24 10:01:57 UTC

We use POI in production and have problems with extended ASCII WingDings.

Standard ASCII characters with values less than 128 are displayed correctly. The
problem is with the chars with 
ASCII values 128 through 255. 

When I open the generated workbook I see the 'unknown' glyph in positions where
my extended WingDings should be.
But If I switch the font to Arial and then back to WingDings I see the correct
glyphs. It tells me that POI stores 
the correct character values but something else is missing which prevents Excel
from displaying them correctly. 

See the attached test case.  I also have this problem when I try to use
WingDings in the office drawing and put 
WingDings in a text box.

Regards, Yegor Kozlov
Comment 1 Yegor Kozlov 2006-04-24 10:03:00 UTC
Created attachment 18161 [details]
test case
Comment 2 Yegor Kozlov 2006-04-24 13:03:29 UTC
Created attachment 18165 [details]
sample workbook with extended ascii wingdings
Comment 3 Yegor Kozlov 2006-04-25 09:53:08 UTC

I found what is wrong.
If you deal with symbolic fonts like Wingdings you need to set the correct
character set.
This is the important setting. 

I added the required modifiers to org.apache.poi.hssf.usermodel.HSSFFont. 

So if you work with Wingdings  you need to set the charset as follows:

 HSSFFont hssfFont = wb.createFont();
 hssfFont.setCharSet(HSSFFont.SYMBOL_CHARSET); //this is the important setting!
After I applied this change I could see the correct glyphs. 
It works both for text in cells and in text box in escher graphics.

Regards, Yegor Kozlov
Comment 4 Yegor Kozlov 2006-04-25 09:53:47 UTC
Created attachment 18179 [details]
patch for HSSFFont
Comment 5 Yegor Kozlov 2006-04-25 09:54:22 UTC
Created attachment 18180 [details]
HSSFFont which can modify charset
Comment 6 Nick Burch 2006-06-16 14:58:39 UTC
OK, I've applied your patch

However, I think it's not very "usermodel" like to require people to know to
change the characterset after changing the font.

What do people think about having a list of fonts which require the alternate
character set, and having setFontName() try to do the right thing?