java - 双引号中的值在导出到 Excel 时不起作用

标签 java excel

在我用 java 编写的导出到 Excel 功能中,双引号中的值在下载的 Excel 中消失了。有没有解决这个问题的方法?

最佳答案

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();
        }
}

关于java - 双引号中的值在导出到 Excel 时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21446582/

相关文章:

java - 如何找到Spring Data JPA和Spring版本的正确jar文件

excel - 以下代码行之间的区别

java - 使用Java Excel库在java中写入excel - 无法打开文件

java - Java中的Biff异常

excel - 使用 VBA 代码从数据列创建 Pivot 的问题

excel - 如何用公式锁定单元格?

java - 如何根据设备有效地更改布局

java - 什么是反射以及为什么它有用?

java - 如何在 Vaadin 中迭代 ComboBox?

java - 这个类对于不同线程来说线程安全吗?