//EXCEL表的名
String fileName = url+currDate+Book_Name;
//获得WORKBOOK
HSSFWorkbook wb = new HSSFWorkbook();
//获得EXCEL表的名
FileOutputStream fos = new FileOutputStream(fileName);
//例子名
ArrayList arraylist = new ArrayList();
arraylist.add("语文");
arraylist.add("数学");
int arraylength = arraylist.size();
//设置编码
//cell.setEncoding((short) HSSFCell.CELL_TYPE_STRING);
for(int len=0;len<arraylength;len++){
String name = (String)arraylist.get(len);
//获取SHEET名
HSSFSheet sheet = wb.createSheet(name);
for(int i=0;i<26;i++){
//获得行
HSSFRow row = sheet.createRow((short)i);
for(int j=0;j<26;j++){
// HSSFCell cell = null;
// cell.setEncoding((short) HSSFCell.CELL_TYPE_STRING);
//获得单元格
// row.createCell((short)j).setEncoding((short) HSSFCell.ENCODING_UTF_16);
//row.createCell((short)j).setEncoding(HSSFCell.ENCODING_UTF_16);
HSSFCell cell = row.createCell((short)j);
// cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setEncoding((short)HSSFCell.ENCODING_UTF_16);
row.createCell((short)j).setCellValue("靠不出来");
}
}
}
//数据WRITE
wb.write(fos);
//关闭本次数据流写入
fos.close();
写了cell.setEncoding(HSSFCell.ENCODING_UTF_16); 照样出现乱码。。
帮看看 那里写得不对
回复 更多评论