Prev
Type
ExcelExplorer Manual Next
Data


EECell::PlainData

(ExcelExplorer 4.0)

Returns unformatted cell data.

mixed PlainData(  )
Parameters
None
Description

Returns unformatted cell data. No numeric format applied to the data. For instance if number formatted as date in the cell this method returns number, not date string. In order to obtain data with numeric format applied use Data() method.

However returned data can still contains rich-text and asian phonetic info (for EE_CELL_TEXT cells).

The following table shows what this method will returns for different cell types (see Type()):

Cell type Returning PHP type Description
EE_CELL_EMPTY,
EE_CELL_BLANK,
EE_CELL_MERGED
NULL Always returns NULL.
EE_CELL_NUMBER integer or float Number returned as it stored in Excel file (integer or float).
EE_CELL_TEXT EEData object Returns EEData object. To retrieve string data or obtain info about rich-text and asian phonetic use methods provided by EEData class.
EE_CELL_LOGICAL boolean Returns boolean TRUE or FALSE.
EE_CELL_ERROR integer Returns error code. Possible values are:

Error code Excel error message Description
EE_ERROR_NULL #NULL! Intersection of two cell ranges is empty
EE_ERROR_DIV0 #DIV/0! Division by zero
EE_ERROR_VALUE #VALUE! Wrong type of operand
EE_ERROR_REF #REF! Illegal or deleted cell reference
EE_ERROR_NAME #NAME? Wrong function or range name
EE_ERROR_NUM #NUM! Value range overflow
EE_ERROR_NA #N/A! Argument or function not available

Worksheet that used in the example below:

A B C
1
2 1,234
3 TRUE
4 #DIV/0!
5 Some text
6 13:45:53
6

Print cell types and their unformatted values (note the difference to Data() example)


<?php


$area 
$ee->Worksheet(0)->UsedArea();
if( 
$area !== false ) {

  for( 
$col $area->FirstColumn(); $col <= $area->LastColumn(); $col++ ) {
    for( 
$row $area->FirstRow(); $row <= $area->LastRow(); $row++ ) {

      echo 
'Cell in column '.$col.', row '.$row.' have type: ';

      
$cell_type $ee->Cell(0,$col,$row)->Type();
      switch( 
$cell_type ) {
        case 
EE_CELL_EMPTY:
          echo 
'EE_CELL_EMPTY'; break;
        case 
EE_CELL_BLANK:
          echo 
'EE_CELL_BLANK'; break;
        case 
EE_CELL_NUMBER:
          echo 
'EE_CELL_NUMBER'; break;
        case 
EE_CELL_TEXT:
          echo 
'EE_CELL_TEXT'; break;
        case 
EE_CELL_LOGICAL:
          echo 
'EE_CELL_LOGICAL'; break;
        case 
EE_CELL_ERROR:
          echo 
'EE_CELL_ERROR'; break;
        case 
EE_CELL_MERGED:
          echo 
'EE_CELL_MERGED'; break;
        default:
          echo 
'UNKNOWN'; break;
      }

      if( (
$cell_type != EE_CELL_EMPTY) && ($cell_type != EE_CELL_BLANK) && ($cell_type != EE_CELL_MERGED) ) {

        echo 
', value: ';

        if( 
$cell_type == EE_CELL_TEXT ) {
          
var_export($ee->Cell(0,$col,$row)->PlainData()->Plain());
        } else {
          
var_export($ee->Cell(0,$col,$row)->PlainData());
        }

      }

      echo 
"\n";

    }
  }

}

?>

Will output:

Cell in column 1, row 1 have type: EE_CELL_NUMBER, value: 1.234
Cell in column 1, row 2 have type: EE_CELL_LOGICAL, value: true
Cell in column 1, row 3 have type: EE_CELL_ERROR, value: 7
Cell in column 1, row 4 have type: EE_CELL_TEXT, value: 'Some text'
Cell in column 1, row 5 have type: EE_CELL_NUMBER, value: 0.57353009259259

 
Prev
Type
Home
Up
Next
Data

 
© 2002-2009 EEPHP.com
All Rights Reserved.