excel - write .xlsx file in java using poi with chinese characters -
i trying create .xlsx file using apache poi . working fine arbaric , hindi etc characters . in application using chinese characters also. when creating .xlsx file using code chinese character not show . using code creating .xlsx file.
workbook wb = new hssfworkbook(); sheet sheet = wb.createsheet("new sheet"); // create row , put cells in it. rows 0 based. row row = sheet.createrow(1); // create cell , put value in it. cell cell = row.createcell(1); //arbaric char set in cell , show in .xlsx cell.setcellvalue("سلام"); cell cell2 = row.createcell(2); **//chinese char set in cell , not show in .xlsx** cell2.setcellvalue(" 邓敏 "); cell cell3 = row.createcell(3); //hindi char set in cell here , show in .xlsx cell3.setcellvalue("हिन्दी"); // write output file fileoutputstream fileout = new fileoutputstream("workbook5.xlsx"); wb.write(fileout); fileout.close();
can me how can write chinese character in .xlsx file using apache poi library . below attach .xlsx file output.thanks in advance
there known bugs in apache poi related called "surrogate pairs" in unicode, see https://bz.apache.org/bugzilla/show_bug.cgi?id=58247 , https://bz.apache.org/bugzilla/show_bug.cgi?id=54084.
unfortunately not easy fix happens deep inside library. can try other chinese characters, if of them work , don't, same issue.
there work on fixing third party lib, see https://bz.apache.org/bugzilla/show_bug.cgi?id=59268, can try replace xmlbeans-jar 1 http://mvnrepository.com/artifact/com.github.pjfanning/xmlbeans , see if fixes problem. if try please comment on bug know works!
Comments
Post a Comment