Thank you Dominik. Using 'com.github.pjfanning:xmlbeans:2.6.2' fixes the issue.
On 9/8/17, 11:17 AM, "Dominik Stadler" <[email protected]> wrote: Hi, You might hit a known bug in XMLBeans, the library that POI currently uses for serializing the XML data, see https://bz.apache.org/bugzilla/show_bug.cgi?id=54084 and https://bz.apache.org/bugzilla/show_bug.cgi?id=59268 for quite some discussion on this issues. You may be able to use a beta-version of a newer XMLBeans version from https://github.com/pjfanning/xmlbeans/releases/tag/2.6.2, we would be interested if this also resolves your problem. Thanks... Dominik. On Fri, Sep 8, 2017 at 5:50 PM, John Brainard <[email protected]> wrote: > Iβm using JXLS to generate a report in Excel and am having a hard time > with non-ASCII text, such as the following: > > π¦ = ππ₯ + π, π΄π₯ + π΅π¦ = πΆ, and π¦ - π¦β = π(π₯ - π₯β) > > The above is rendered to the sharedStrings.xml file as: > > <sst count="1" uniqueCount="1" xmlns="http://schemas.openxmlformats.org/ > spreadsheetml/2006/main"><si><t>?? = ???? + ??, ???? + ???? = ??, and ?? > - ??β = ??(?? - ??β)</t></si></sst> > > I believe Iβve narrowed it down to org.openxmlformats.schemas. > spreadsheetml.x2006.main.CTRst. My testing shows that itβs storing the > string correctly internally, but when writing to the sharedStrings.xml, the > text isnβt being handled correctly. Iβm not sure if this is something Iβm > doing wrong, or if this is a bug somewhere in POI or XmlBeans. I donβt > believe the issue is in the JXLS library as Iβve isolated the issue to the > code below: > > String text = "π¦ = ππ₯ + π, π΄π₯ + π΅π¦ = πΆ, and π¦ - π¦β = > π(π₯ - π₯β)"; > SharedStringsTable table = new SharedStringsTable(); > CTRst st = CTRst.Factory.newInstance(); > st.setT(text); > table.addEntry(st); > > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > table.writeTo(baos); > String output = baos.toString("UTF-8"); > > // This assertion passes > Assert.assertEquals(st.getT(), text); > > // This assertion fails > Assert.assertEquals(output, "<?xml version=\"1.0\" > encoding=\"UTF-8\"?>\n" + > "<sst count=\"1\" uniqueCount=\"1\" xmlns=\" > http://schemas.openxmlformats.org/spreadsheetml/2006/main\"><si><t>π¦ = > ππ₯ + π, π΄π₯ + π΅π¦ = πΆ, and π¦ - π¦β = π(π₯ - π₯β)</t></si></sst>"); > > > Hereβs another snippet which reproduces the issue Iβm having with creating > a xlsx workbook: > > XSSFWorkbook workbook = new XSSFWorkbook(); > XSSFSheet sheet = workbook.createSheet(); > > Row row = sheet.createRow(0); > Cell cell = row.createCell(0); > cell.setCellValue(TEXT); > > FileOutputStream outputStream = new FileOutputStream(FILE_NAME); > workbook.write(outputStream); > workbook.close(); > > > Iβm assuming itβs something Iβm doing wrong, but have been unable to find > a solution. I created a github repo with the above code in hopes that it > aids in finding a solution. > > https://github.com/JohnBrainard/poi-utf8-debugging > > Thank you for your help! > > John > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] >
