java 怎么读取excel单元格上悬浮的新公式

Java 未结 2 177
349444073
349444073 剑圣 2024-06-22 17:41

一、该问题的重现步骤是什么?

1. poi-5.2.2 poi-ooxml-5.2.2

2. 

3.


二、你期待的结果是什么?实际看到的又是什么?


三、你正在使用的是什么产品,什么版本?在什么操作系统上?


四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。

2条回答
  • 试下这个例子:

    import org.apache.poi.ss.usermodel.*;


    import java.io.FileInputStream;

    import java.io.IOException;


    public class ReadExcel {

        public static void main(String[] args) throws IOException {

            String filePath = "example.xlsx";

            FileInputStream inputStream = new FileInputStream(filePath);

            Workbook workbook = WorkbookFactory.create(inputStream);

            Sheet sheet = workbook.getSheetAt(0);

            Row row = sheet.getRow(0);

            Cell cell = row.getCell(0);


            Comment comment = cell.getCellComment();

            if (comment != null) {

                String formula = comment.getString().getString();

                System.out.println("单元格上悬浮的新公式为:" + formula);

            } else {

                System.out.println("单元格上没有悬浮的新公式");

            }


            workbook.close();

            inputStream.close();

        }

    }


    0 讨论(0)
  • 2024-06-22 19:36

    Comment comment = cell.getCellComment();

    读取不到悬浮的新公式

    0 讨论(0)
提交回复