I am using [PHPExcel](http://phpexcel.codeplex.com/) to read data out of Excel files.

With the following code, I am able to read **one particular worksheet** out of a **3MB** Excel file in just a couple seconds. Works nicely.

However, I now have **27MB** and **88MB** Excel files which I need to get data out of. They are so large that even **OpenOffice** cannot open them.

I have found that I can use an index number instead of a name when I load a sheet, but this seems inconsistent, e.g. in one particular Excel file `setLoadSheetsOnly(0)` gave me the **third** sheet while `setLoadSheetsOnly(1)` gave me an **error** even though there were four worksheets in the file. So that seems **unreliable** for some reason.

**Is there a way I can read out the names of the worksheets from a large file so that I can access only one of its worksheets at a time?**

```
        $objReader = PHPExcel_IOFactory::createReaderForFile("data/" . $file_name);
        $objReader->setLoadSheetsOnly(array($sheet_name));
        $objReader->setReadDataOnly(true);
        $objPHPExcel = $objReader->load("data/" . $file_name);

        echo '<table border="1">';
        for ($row = 1; $row < $number_of_rows; $row++) {
            echo '<tr>';
            for ($column = 0; $column < $number_of_columns; $column++) {
                $value = $objPHPExcel->setActiveSheetIndex(0)->getCellByColumnAndRow($column, $row)->getValue();
                echo '<td>';
                echo $value . '&nbsp;';
                echo '</td>';
            }
            echo '</tr>';
        }
        echo '</table>';
        die;

```

ADDENDUM:
=========

I found some code that gets close, but it doesn't seem to always be accurate, e.g. here it missed the second worksheet in a 27MB file:

![alt text](https://i.stack.imgur.com/Q37Ic.png)

and here it only got the third worksheet and missed 3 others:

![alt text](https://i.stack.imgur.com/sL8t7.png)

```
$objReader = PHPExcel_IOFactory::createReaderForFile("data/" . $file_name);
$objReader->setLoadSheetsOnly(0);
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("data/" . $file_name);

echo $objPHPExcel->getSheetCount(), ' worksheets<hr/>';
$loadedSheetNames = $objPHPExcel->getSheetNames();
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
    echo $sheetIndex, ' -> ', $loadedSheetName, '<br />';
}
die;

```