我有一个关于如何将汉字写到 jexcel 的问题。
这是我的代码..
nameChinese取自mysql数据库..
public String getNameChinese(String nameChinese)
{
String strNameChinese = "";
try
{
strNameChinese = new String(nameChinese.getBytes("utf-8"), "iso-8859-1");
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
return strNameChinese;
}
}// getNameChinese()
Excel.java
Workbook workbook = Workbook.getWorkbook(new File(templatePath));
WritableWorkbook copy = Workbook.createWorkbook(new File(resultPath + resultFileName), workbook);
WritableSheet sheet = copy.getSheet(0);
Label nameLabel = new Label(1, currentIndex, getNameChinese(), normalAllSideWarpFormat);
sheet.addCell(nameLabel);
copy.write();
copy.close();