在Java中使用poi与中文字符写.xlsx文件

我正在尝试使用apache poi创build.xlsx文件。 这是工作正常与阿尔巴尼亚语和印地文等字符。 但我在我的应用程序,我们也使用汉字。 当我使用我的代码创build.xlsx文件时,只显示中文字符。 我正在使用此代码来创build.xlsx文件。

Workbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet("new sheet"); // Create a row and put some cells in it. Rows are 0 based. Row row = sheet.createRow(1); // Create a cell and put a value in it. Cell cell = row.createCell(1); //arbaric char set in cell and show successfully in .xlsx cell.setCellValue("سلام"); Cell cell2 = row.createCell(2); **//chinese char set in cell and not show in .xlsx** cell2.setCellValue(" 邓敏 "); Cell cell3 = row.createCell(3); //hindi char set in cell here and show successfully in .xlsx cell3.setCellValue("हिन्दी"); // Write the output to a file FileOutputStream fileOut = new FileOutputStream("workbook5.xlsx"); wb.write(fileOut); fileOut.close(); 

任何人都可以帮助我如何使用Apache poi库在.xlsx文件中写中文字符。 下面我附上.xlsx文件的输出。提前感谢 在这里输入图像说明

Apache POI中有一些与Unicode中所谓的“代理对”相关的bug,请参阅https://bz.apache.org/bugzilla/show_bug.cgi?id=58247和https://bz.apache.org/ bugzilla / show_bug.cgi?id = 54084 。

不幸的是,修复它并不容易,因为它发生在另一个库的内部。 你可以尝试一些其他的汉字,如果其中一些工作,只有一些没有,那么可能是同样的问题。

有关修复第三方库的一些工作,请参阅https://bz.apache.org/bugzilla/show_bug.cgi?id=59268 ,您可以尝试用http:// mvnrepository中的 XMLBeans-jarreplace您的XMLBeans-jar .com / artifact / com.github.pjfanning / xmlbeans ,看看是否解决了这个问题。 如果您尝试,请评论错误,所以我们知道它的工作原理!