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/05/13 10:48:36 UTC

DO NOT REPLY [Bug 51193] New: cell.getCellType() throw the null exception

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

             Bug #: 51193
           Summary: cell.getCellType() throw the null exception
           Product: POI
           Version: 3.7
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: POI Overall
        AssignedTo: dev@poi.apache.org
        ReportedBy: julia.faifer@capgemini.com
    Classification: Unclassified


Created attachment 26994
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=26994
The used Excel-File  with Exception

Hi ,
I use the liblary poi-3.7-20101029.jar. By reading an excel-File in the
function
cell.getCellType() throw null exception.

-- 
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 51193] cell.getCellType() throws the null exception

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

--- Comment #1 from mai00ihf <ju...@capgemini.com> 2011-05-13 09:06:23 UTC ---
The exception is thrown by reading the attachment file in the row number 1.

-- 
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 51193] cell.getCellType() throws the null exception

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

--- Comment #4 from mai00ihf <ju...@capgemini.com> 2011-05-26 09:13:24 UTC ---
i get the exception, if the cell is cell.getCellType(). i think,
you have right.

-- 
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 51193] cell.getCellType() throws the null exception

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

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #2 from Nick Burch <ni...@alfresco.com> 2011-05-13 09:09:28 UTC ---
Are you sure that your variable cell isn't null?

Can you please post the code required to trigger your problem?

-- 
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 51193] cell.getCellType() throws the null exception

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

--- Comment #3 from mai00ihf <ju...@capgemini.com> 2011-05-26 09:09:18 UTC ---
        Cell cell =
sheet.getRow(getIntValueRowID(rowID)).getCell(getIntValue(colID));
             //      System.out.println("Type " + cell.getCellType());


                   //System.out.println( cell.getCellStyle());

                   switch(cell.getCellType()) {
                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
                    value = cell.getStringCellValue();                          
                    break;
                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
                   
if(org.apache.poi.hssf.usermodel.HSSFDateUtil.isCellDateFormatted(cell)) {
                        value = cell.getDateCellValue().toString();             
                    } else {
                        value = cell.getNumericCellValue() +"";                 
                    }
                    break;
                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN:
                    value = Boolean.toString(cell.getBooleanCellValue());       
                    break;

                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
                    value = null;
                    break;

                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK:
                    value=null;
                    break;

                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
                    //Formula cells have the formula string, as well as the
formula result, which can be numeric or string.                
                    try{
                        // get the formula result as string
                        value = cell.getStringCellValue();    
                    }    
                    catch (Exception e) {
                        //wenn eine Exception ausfällt, dann gib es als ein
Number wert zurück
                        value = Double.toString((cell.getNumericCellValue()));  
                    }
                    break;                    
                default:
                    value = null;
                    break;
                }

                String errorMessage = null;

                if (checkEmpty && (value == null || value.length() == 0)) {
                        errorMessage = "Wert in Feld: " + colID + rowID + " ist
leer!";
                } else if (datatype != null) {
                    if (!checkDataType(value, datatype)) {                    
                       // vorgegeben typen: String, numerische datens           
                        errorMessage = TEXT_UNERWARTET + colID + rowID + ",
Arbeitsblatt: " + sheetName + " Erwartet war: "+ datatype;
                    }
                }    
                // Fehler Ausgeben falls vorhanden
                if (errorMessage != null) {
                    handleError(errorMessage);
                }
            }catch(Exception e){
                //throw new ContentAccessException("Zugriff auf Zelle " + colID
+ rowID + " nicht möglich." + e.getMessage());
                 String message = "Zugriff auf Zelle " + colID + rowID + "
nicht möglich."+ e.getMessage();
                 reportError(message);
            }

-- 
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 51193] cell.getCellType() throws the null exception

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

mai00ihf <ju...@capgemini.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|cell.getCellType() throw    |cell.getCellType() throws
                   |the null exception          |the null exception

-- 
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 51193] cell.getCellType() throws the null exception

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

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|                            |INVALID

--- Comment #5 from Nick Burch <ni...@alfresco.com> 2011-05-26 10:54:27 UTC ---
You don't appear to be checking that a cell isn't null after retrieving it, but
before asking for the type. Cells may not be there, if they're not in the file,
unless you have set a MissingCellPolicy

Check the cell is there before using it and you'll be fine

-- 
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