For God so loved the world, that He gave His only begotten Son, that all who believe in Him should not perish but have everlasting life
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6 KiB

  1. # PHPExcel User Documentation – Reading Spreadsheet Files
  2. ## Helper Methods
  3. 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.
  4. ### listWorksheetNames
  5. The `listWorksheetNames()` method returns a simple array listing each worksheet name within the workbook:
  6. ```php
  7. $objReader = PHPExcel_IOFactory::createReader($inputFileType);
  8. $worksheetNames = $objReader->listWorksheetNames($inputFileName);
  9. echo '<h3>Worksheet Names</h3>';
  10. echo '<ol>';
  11. foreach ($worksheetNames as $worksheetName) {
  12. echo '<li>', $worksheetName, '</li>';
  13. }
  14. echo '</ol>';
  15. ```
  16. > See Examples/Reader/exampleReader18.php for a working example of this code.
  17. ### listWorksheetInfo
  18. The `listWorksheetInfo()` method returns a nested array, with each entry listing the name and dimensions for a worksheet:
  19. ```php
  20. $objReader = PHPExcel_IOFactory::createReader($inputFileType);
  21. $worksheetData = $objReader->listWorksheetInfo($inputFileName);
  22. echo '<h3>Worksheet Information</h3>';
  23. echo '<ol>';
  24. foreach ($worksheetData as $worksheet) {
  25. echo '<li>', $worksheet['worksheetName'], '<br />';
  26. echo 'Rows: ', $worksheet['totalRows'],
  27. ' Columns: ', $worksheet['totalColumns'], '<br />';
  28. echo 'Cell Range: A1:',
  29. $worksheet['lastColumnLetter'], $worksheet['totalRows'];
  30. echo '</li>';
  31. }
  32. echo '</ol>';
  33. ```
  34. > See Examples/Reader/exampleReader19.php for a working example of this code.