commit | author | age
|
2207d6
|
1 |
# PHPExcel User Documentation – Reading Spreadsheet Files |
W |
2 |
|
|
3 |
|
|
4 |
## Helper Methods |
|
5 |
|
|
6 |
You can retrieve a list of worksheet names contained in a file without loading the whole file by using the Reader’s `listWorksheetNames()` method; similarly, a `listWorksheetInfo()` method will retrieve the dimensions of worksheet in a file without needing to load and parse the whole file. |
|
7 |
|
|
8 |
### listWorksheetNames |
|
9 |
|
|
10 |
The `listWorksheetNames()` method returns a simple array listing each worksheet name within the workbook: |
|
11 |
|
|
12 |
```php |
|
13 |
$objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
14 |
|
|
15 |
$worksheetNames = $objReader->listWorksheetNames($inputFileName); |
|
16 |
|
|
17 |
echo '<h3>Worksheet Names</h3>'; |
|
18 |
echo '<ol>'; |
|
19 |
foreach ($worksheetNames as $worksheetName) { |
|
20 |
echo '<li>', $worksheetName, '</li>'; |
|
21 |
} |
|
22 |
echo '</ol>'; |
|
23 |
``` |
|
24 |
> See Examples/Reader/exampleReader18.php for a working example of this code. |
|
25 |
|
|
26 |
### listWorksheetInfo |
|
27 |
|
|
28 |
The `listWorksheetInfo()` method returns a nested array, with each entry listing the name and dimensions for a worksheet: |
|
29 |
|
|
30 |
```php |
|
31 |
$objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
32 |
|
|
33 |
$worksheetData = $objReader->listWorksheetInfo($inputFileName); |
|
34 |
|
|
35 |
echo '<h3>Worksheet Information</h3>'; |
|
36 |
echo '<ol>'; |
|
37 |
foreach ($worksheetData as $worksheet) { |
|
38 |
echo '<li>', $worksheet['worksheetName'], '<br />'; |
|
39 |
echo 'Rows: ', $worksheet['totalRows'], |
|
40 |
' Columns: ', $worksheet['totalColumns'], '<br />'; |
|
41 |
echo 'Cell Range: A1:', |
|
42 |
$worksheet['lastColumnLetter'], $worksheet['totalRows']; |
|
43 |
echo '</li>'; |
|
44 |
} |
|
45 |
echo '</ol>'; |
|
46 |
``` |
|
47 |
> See Examples/Reader/exampleReader19.php for a working example of this code. |