Prev
EECell class
ExcelExplorer Manual Next
PlainData


EECell::Type

(ExcelExplorer 4.0)

Get cell type.

integer Type(  )
Parameters
None
Description

Returns cell type. Possible values are:

Constant Description
EE_CELL_EMPTY Empty (undefined) cell. This cell have no data and not stored in the Excel file, but can have some styles settings that applied for the column or row that contains specified cell.
EE_CELL_BLANK In contrast to EE_CELL_EMPTY this cell is defined and stored in the Excel file, have it's own styles settings (font, numeric format, border, etc.), but have no data stored in it.
EE_CELL_NUMBER Number stored in the cell (integer or float). This cell type used also for percentage, date and others. See Data() method for more information about how to obtain formatted values (e.g. date) from the cell.
EE_CELL_TEXT Cell contains some text data. Note that in rare cases text can be empty ("") string (for example, in formula result). This type also will be returned if number in the cell formatted as text ("Text" format applied - "@").
EE_CELL_LOGICAL Cell contains logical value (TRUE or FALSE).
EE_CELL_ERROR Cell contains error code ("#DIV/0!", "#VALUE!", etc.). See PlainData() to get info about possible error codes.
EE_CELL_MERGED Cell within merged cells area (see Merged()).

Worksheet that used in the example below:

A B C D E F G
1
2 text
3 text merged
4 text
5
6
7

1. Print cell types from the defined area in the worksheet above


<?php


$area 
$ee->Worksheet(0)->DefinedArea();
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: ';

      switch( 
$ee->Cell(0,$col,$row)->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;
      }

      echo 
"\n";

    }
  }

}

?>

Will output:

Cell in column 1, row 1 have type: EE_CELL_TEXT
Cell in column 1, row 2 have type: EE_CELL_EMPTY
Cell in column 1, row 3 have type: EE_CELL_EMPTY
Cell in column 1, row 4 have type: EE_CELL_EMPTY
Cell in column 1, row 5 have type: EE_CELL_EMPTY
Cell in column 2, row 1 have type: EE_CELL_EMPTY
Cell in column 2, row 2 have type: EE_CELL_TEXT
Cell in column 2, row 3 have type: EE_CELL_EMPTY
Cell in column 2, row 4 have type: EE_CELL_EMPTY
Cell in column 2, row 5 have type: EE_CELL_EMPTY
Cell in column 3, row 1 have type: EE_CELL_EMPTY
Cell in column 3, row 2 have type: EE_CELL_TEXT
Cell in column 3, row 3 have type: EE_CELL_TEXT
Cell in column 3, row 4 have type: EE_CELL_EMPTY
Cell in column 3, row 5 have type: EE_CELL_EMPTY
Cell in column 4, row 1 have type: EE_CELL_EMPTY
Cell in column 4, row 2 have type: EE_CELL_MERGED
Cell in column 4, row 3 have type: EE_CELL_EMPTY
Cell in column 4, row 4 have type: EE_CELL_EMPTY
Cell in column 4, row 5 have type: EE_CELL_EMPTY
Cell in column 5, row 1 have type: EE_CELL_EMPTY
Cell in column 5, row 2 have type: EE_CELL_EMPTY
Cell in column 5, row 3 have type: EE_CELL_EMPTY
Cell in column 5, row 4 have type: EE_CELL_EMPTY
Cell in column 5, row 5 have type: EE_CELL_BLANK


2. Print cell types from the used area in the worksheet above


<?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: ';

      switch( 
$ee->Cell(0,$col,$row)->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;
      }

      echo 
"\n";

    }
  }

}

?>

Will output:

Cell in column 1, row 1 have type: EE_CELL_TEXT
Cell in column 1, row 2 have type: EE_CELL_EMPTY
Cell in column 1, row 3 have type: EE_CELL_EMPTY
Cell in column 2, row 1 have type: EE_CELL_EMPTY
Cell in column 2, row 2 have type: EE_CELL_TEXT
Cell in column 2, row 3 have type: EE_CELL_EMPTY
Cell in column 3, row 1 have type: EE_CELL_EMPTY
Cell in column 3, row 2 have type: EE_CELL_TEXT
Cell in column 3, row 3 have type: EE_CELL_TEXT
Cell in column 4, row 1 have type: EE_CELL_EMPTY
Cell in column 4, row 2 have type: EE_CELL_MERGED
Cell in column 4, row 3 have type: EE_CELL_EMPTY

 
Prev
EECell class
Home
Up
Next
PlainData

 
© 2002-2009 EEPHP.com
All Rights Reserved.