Deepa Huddar
Deepa Huddar

Reputation: 341

Apache POI- Unable to read the content of the cell

I am trying to read the content of the cell which contains a large string. But the Cell read is giving it as blank.The cell containing the large string is not extracted, whereas the other cell data is extracted.

try{
        FileInputStream inputStream = new FileInputStream(new File(strFileName));
        Workbook workbook = new XSSFWorkbook(inputStream);
        Sheet sheetName=null;
        sheetName = workbook.getSheet(strSheetName);
        Iterator<Row> iterator = sheetName.iterator();

        while (iterator.hasNext()) {
            if(blnHasHeader){
                //  Data starts from next row
                iterator.next();
                blnHasHeader=false;
                continue;
            }
            ArrayList<String> arrRow = new ArrayList<String>();
            Row nextRow = iterator.next();
            Iterator<Cell> cellIterator = nextRow.cellIterator();
            while (cellIterator.hasNext()) {
                Cell cell = cellIterator.next();
                switch (cell.getCellType()) {
                case Cell.CELL_TYPE_STRING:
                    arrRow.add(String.valueOf(cell.getStringCellValue()));
                    System.out.println(String.valueOf(cell.getStringCellValue()));
                    break;
                case Cell.CELL_TYPE_BOOLEAN:
                    arrRow.add(String.valueOf(cell.getBooleanCellValue()));
                    break;
                case Cell.CELL_TYPE_NUMERIC:
                    arrRow.add(String.valueOf(cell.getNumericCellValue()));
                    System.out.println(String.valueOf(cell.getNumericCellValue()));
                    break;
                case Cell.CELL_TYPE_BLANK:
                    arrRow.add("");
                    System.out.println("Blank");
                    break;
                }

            }
            arrReturnArrayList.add(arrRow); 
        }
        workbook.close();
        inputStream.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

Is there any limit on the length of the string to be read?

Upvotes: 0

Views: 363

Answers (1)

XtremeBaumer
XtremeBaumer

Reputation: 6435

public static final SpreadsheetVersion EXCEL2007 Excel2007

The total number of available rows is 1M (2^20)

The total number of available columns is 16K (2^14)

The maximum number of arguments to a function is 255

Number of conditional format conditions on a cell is unlimited (actually limited by available memory in Excel)

Number of cell styles is 64000

Length of text cell contents is 32767

taken from here: https://poi.apache.org/apidocs/org/apache/poi/ss/SpreadsheetVersion.html

i hope this answers your question. you should have a look on how many characters the cell contains

Upvotes: 1

Related Questions