小编Sab*_*ber的帖子

如何使用Apache POI从Java的合并单元格读取?

我有一个.xlsx格式的Excel文件.我通过合并单元格来形成各种列来存储数据.我正在通过Java Web应用程序读取Excel文件并将其数据保存到数据库(MySQL).但是当我从合并的单元格中读取时,我得到的是空值以及存储在列和标题中的内容.我正在使用Apache POI.我的代码是:

public static void excelToDBLogIN() {

    FileInputStream file = null;
    Boolean flag = true;
    ArrayList<String> rows = new ArrayList<String>();
    try {


        // here uploadFolder contains the path to the Login 3.xlsx file

        file = new FileInputStream(new File(uploadFolder + "Login 3.xlsx"));

        //Create Workbook instance holding reference to .xlsx file
        XSSFWorkbook workbook = new XSSFWorkbook(file);

        //Get first/desired sheet from the workbook
        XSSFSheet sheet = workbook.getSheetAt(0);

        //Iterate through each rows one by one
        Iterator<Row> rowIterator = sheet.iterator();


        while (rowIterator.hasNext()) {
            Row …
Run Code Online (Sandbox Code Playgroud)

java apache cell import-from-excel apache-poi

12
推荐指数
1
解决办法
2万
查看次数

标签 统计

apache ×1

apache-poi ×1

cell ×1

import-from-excel ×1

java ×1