首页 > 解决方案 > 如何使用 java POI 从日期单元格中获取原始文本

问题描述

在此处输入图像描述

细胞参考细胞参考 = 新细胞参考(当前);// 传递包含公式的单元格

                        CellValue cellValue = evaluator.evaluate(current);
                        System.out.println("Cell value : "+cellValue.getNumberValue()); // 44319.0
                        cellValue.getStringValue(); // Null
                        
                        
                        DataFormatter formatter = new DataFormatter(); 
                        String strValue = formatter.formatCellValue(current); 
                        System.out.println("strValue :- "+strValue); // 5/3/21
                        
                         String data0 = String.valueOf(current.getNumericCellValue());
                         System.out.println("data0 :- "+data0); //44319.0
                         
                        String value = formatter.formatCellValue(current, evaluator);
                        System.out.println("value :- "+value); //5/3/21
                        
    System.out.println("Date value :- "+current.getDateCellValue()); // Mon May 03 00:00:00 IST 2021

但我需要将 RAW 值作为 03/05/2021 作为文本。

标签: javaapache-poi

解决方案


推荐阅读