在我用java编写的excel功能导出中,双引号中的值在下载的excel中消失了。这个有什么工作吗?
答案 0 :(得分:1)
How you are trying to export the data into excel? please post?
Simple example with Apache POI-
{
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Test Export");
Map<String, Object[]> data = new HashMap<String, Object[]>();
//cell value in double quotes
data.put("2", new Object[] {"1", "\"abc\""});
data.put("3", new Object[] {"2", "\"xyz\""});
Set<String> keyset = data.keySet();
int rownum = 0;
for (String key : keyset) {
Row row = sheet.createRow(rownum++);
Object [] objArr = data.get(key);
int cellnum = 0;
for (Object obj : objArr) {
Cell cell = row.createCell(cellnum++);
cell.setCellValue((String)obj);
}
}
try {
FileOutputStream out =new FileOutputStream(new File("/home/rahul/Desktop/testExport.xls"));
workbook.write(out);
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}