小编Paw*_*dey的帖子

按列名apache poi excel获取数据

我正在使用apache POI进行excel导入和解析.我必须通过传递列名来获取数据.

这是我的代码

JSONObject jo = new JSONObject();
        JSONArray dataCollection = new JSONArray();
        JSONObject data = null;
        try {
            String tempCampaignFilesPath = getSessionData("userPath") + System.getProperty("file.separator") + "tempCampaignFiles";
            File someFile = new File(tempCampaignFilesPath, fileName);

            /* read from this file */

            FileInputStream fileInputStream = new FileInputStream(someFile);
            HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);
            HSSFSheet sheet = workbook.getSheet(sheetName);
            int rowNum = sheet.getLastRowNum() + 1;
            int colNum = sheet.getRow(0).getLastCellNum();
            Row row = null;
            Cell cell = null;

            for (int i = 1; i < rowNum; i++) …
Run Code Online (Sandbox Code Playgroud)

java apache-poi

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

标签 统计

apache-poi ×1

java ×1