Prev
IsEmpty
ExcelExplorer Manual Next
UsedArea


EEWorksheet::DefinedArea

(ExcelExplorer 4.0)

Returns defined area in the current sheet (area contains defined columns, rows, or cells - even blank).

false EEArea DefinedArea(  )
Parameters
None
Description

This method returns cells area (EEArea object) that is defined. Returns FALSE if worksheet is undefined or if it defined but have no defined columns, rows or cells. Therefore you should always check returned value if it valid object before using its methods.

It is useful when you need to obtain area that have not only cells with actual data in it but also cells, columns and rows that can be blank but have some custom styles, like borders, background color, etc. (see cell types). If you don't need to get information about styles, width and other but only the cells that contains actual data use UsedArea method.

To understand how it works look at the example below:

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

Sheet contains three cells with data ("text" strings), cells D3 and E3 are merged and contains text "merged", column "F" that have right border set and row 6 with custom background color. Note that background color applied to the whole row not to individual cells. This method called for such sheet will returns area [B2:F6].

What data takes in account:

  • Cell considered as defined if it have some data and/or any style settings, like borders, alignment, etc. Note that all cells that belongs to the merged cells area are also considered as defined (cells D3 and E3 in the example above - cell D3 contains text "merged" and cell E3 not contains actual data but within merged cells area).
  • Blank and empty cells considered as undefined.
  • Row considered as defined if it have any setting that differ from default row settings. This includes custom row height, grouping level, visibility, any applied style.
  • The same rule applied for columns except one: if column have only width changed and no other settings are changed it is considered as undefined. This is because of how Excel store the file but not how ExcelExplorer reads it. In other words this is the feature of Excel, not ExcelExplorer.

Method returns EEArea object that can be used to obtain area dimensions using its methods.

Prints dimensions of defined area from the example above


<?php


$area 
$ee->Worksheet(0)->DefinedArea();
if( 
$area !== false ) {
  echo 
'First defined column: '.$area->FirstColumn()."\n";
  echo 
'First defined row: '.$area->FirstRow()."\n";
  echo 
'Last defined column: '.$area->LastColumn()."\n";
  echo 
'Last defined row: '.$area->LastRow()."\n";
}

?>

Will output:

First defined column: 1
First defined row: 1
Last defined column: 5
Last defined row: 5

 
Prev
IsEmpty
Home
Up
Next
UsedArea

 
© 2002-2009 EEPHP.com
All Rights Reserved.