You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2011/11/21 08:34:49 UTC

DO NOT REPLY [Bug 52220] New: unable to read blank cells from excel.

https://issues.apache.org/bugzilla/show_bug.cgi?id=52220

             Bug #: 52220
           Summary: unable to read blank cells from excel.
           Product: POI
           Version: 3.7
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: chaitalimali20@gmail.com
    Classification: Unclassified


does not read blank cells from excel file 
{
XSSFWorkbook workbook = new XSSFWorkbook(fis)

XSSFSheet sheet = workbook.getSheetAt(0);


            Iterator rows = sheet.rowIterator();
            while (rows.hasNext()) {
            XSSFRow row = (XSSFRow) rows.next();
            Iterator cells = row.cellIterator();

            List data = new ArrayList();
            while (cells.hasNext()) {


            XSSFCell cell = (XSSFCell) cells.next();


            data.add(cell);



            }
            //System.out.print(rowCount);

            sheetData.add(data);
            }
            }
        catch (IOException e) {
            e.printStackTrace();
            } 
        {
            if (fis != null) {
            fis.close();
            }
            }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 52220] unable to read blank cells from excel.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52220

--- Comment #3 from Yegor Kozlov <ye...@dinom.ru> 2011-11-21 10:42:13 UTC ---
(In reply to comment #2)
> how can we read excel file without using iterator???

        for(int i = sheet.getFirstRowNum(); i <= sheet.getLastRowNum(); i++){
            Row row = sheet.getRow(i);
            for(int j = row.getFirstCellNum(); j <= row.getLastCellNum(); j++){
                Cell cell = row.getCell(j);    
            }
        }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 52220] unable to read blank cells from excel.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52220

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID
         OS/Version|                            |All

--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> 2011-11-21 10:09:10 UTC ---
As the javadoc states, both Sheet#rowIterator() and Cell#cellIterator() iterate
over the physical data, i.e. they iterate over the rows and cells that are
physically defined in the file. For optimization purposes Excel typically does
not write blank cells and it explains why you are getting only the actual data
cells and not blanks.

For the indexed cell access via Row.getCell(int columnIndex) there is a way to
control the missing cell policy for the case of null and blank cells:


        // return a blank if a cell is null or missing
        workbook.setMissingCellPolicy(Row.RETURN_BLANK_AS_NULL);

        Cell cell = sheet.getRow(0).getCell(0); // never null

Note that MissingCellPolicy works only for indexed access and not for
iterators, that it, no matter what you pass to workbook.setMissingCellPolicy
the cell iterator will always return only physical cells.

Yegor

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 52220] unable to read blank cells from excel.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52220

--- Comment #2 from chaitali <ch...@gmail.com> 2011-11-21 10:37:00 UTC ---
how can we read excel file without using iterator???

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org