POI写EXCEL时中文乱码
public void test() {
try{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow((short)0);
// Create a cell and put a value in it.
HSSFCell cell = row.createCell((short)0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell((short)1).setCellValue(1.2);
row.createCell((short)2).setCellValue("This is a string");
row.createCell((short)3).setCellValue(true);
row.createCell((short)3).setCellValue("这是中文字符");
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("c:/workbook.xls");
wb.write(fileOut);
fileOut.close();
}catch(Exception ex){
}
}
我写的一列row.createCell((short)3).setCellValue("这是中文字符");
这样就出乱码了,请指教