You just need to open the specified .xlsx file. Then it will be corrected and closed manually. Connect external modules PHPExcel:

...\Classes\PHPExcel.php и ...\Classes\PHPExcel\IOFactory.php 

Further so:

 $pExcel = PHPExcel_IOFactory::load("C:\\info\\p_f600.xlsx"); 

Work with a sheet, etc. it turns out, for example, like this:

  // выбираем лист, с которым будем работать; $pExcel->setActiveSheetIndex(0); // получаем активный лист; $aSheet = $pExcel->getActiveSheet(); 

But I just need to open the file. Tell me, please, how to do it.

  • one
    What do you mean by "just open"? Just open in Microsoft Word? Just download and open? Just open as a set of bytes? What? - rjhdby
  • one
    You may understand, but, unfortunately, all telepaths went on vacation. That's where $pExcel = PHPExcel_IOFactory::load("C:\\info\\p_f600.xlsx"); you "just open", but this is probably not it. Then from where does it take you to "close hands" - SHA !? In Russian, explain what you want to achieve. This is straightforward in steps, for example - “I want to break through the file so that the editor starts up and this file opens in it, then fix it and save it with my hands” - rjhdby
  • one
    @rjhdby seems the author wants to run Excel with this file. - teran
  • one
    @Alex do you have a website on your local machine? and need to open right there? If so, try exec() as an argument should be the full path to Excel.exe and the file name parameter. That is, a team that does what you need through Start-Run. Not sure, however, that will start. Because apache / iis work on behalf of the other user. - teran
  • one
    If PHP is running on Windows, then the COM extension will help you. php.net/manual/en/book.com.php - rjhdby

2 answers 2

To execute an external command on the server (or in this case on the local machine where the server is located) use the exec() function

 exec("C:\\info\\p_f600.xlsx"); 

    For PHP running on the Windows platform, an extension is available that allows COM objects to be operated on.

    There is also an example of running Microsoft Word in the documentation . You need, by analogy, to create an object for Excel.

     <?php $ex = new COM("Excel.sheet") or Die ("Did not connect"); $ex->Application->Workbooks->Open("C:\\info\\p_f600.xlsx"); //Если автоматом не будет на передний план выходить, то $ex->Application->Visible = 1; 
    • Comments are not intended for extended discussion; conversation moved to chat . - PashaPash