

You can set the option setReadDataOnly on the reader, to instruct the xlsx file using the following code: $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx() \PhpOffice\PhpSpreadsheet\Reader\Xlsx Reading a spreadsheet Outputting the in-memory spreadsheet to a. Xlsx file format is the main file format of PhpSpreadsheet. \PhpOffice\PhpSpreadsheet\IOFactory: $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, "Xlsx") You can create a \PhpOffice\PhpSpreadsheet\Writer\IWriter instance using Creating \PhpOffice\PhpSpreadsheet\Writer\IWriter using \PhpOffice\PhpSpreadsheet\IOFactory Note that automatic type resolving mode is slightly slower than explicit $spreadsheet = $reader->load("05featuredemo.xlsx") \PhpOffice\PhpSpreadsheet\IOFactory in explicit mode using the followingĬode sample: $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx") Variant: $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile("05featuredemo.xlsx") to only readĭata, see more about this later), then you may instead want to use this If you need to set some properties on the reader, (e.g. Your users, and you don’t know whether they are uploading xls or xlsx Mode using the following code sample: $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load("05featuredemo.xlsx") Ī typical use of this feature is when you need to read files uploaded by

\PhpOffice\PhpSpreadsheet\IOFactory in automatic file type resolving You can create a \PhpOffice\PhpSpreadsheet\Reader\IReader instance using \PhpOffice\PhpSpreadsheet\Reader\IReader should be used. If one of them can load the specified file name, theįile is loaded using that \PhpOffice\PhpSpreadsheet\Reader\IReader.Įxplicit mode requires you to specify which \PhpOffice\PhpSpreadsheet\Reader\IReader distributed with There are 2 methods for reading in a file into PhpSpreadsheet: usingĪutomatic file type resolving or explicitly.Īutomatic file type resolving checks the different Creating \PhpOffice\PhpSpreadsheet\Reader\IReader using \PhpOffice\PhpSpreadsheet\IOFactory Note that you canĪlso use the \PhpOffice\PhpSpreadsheet\IOFactory class to do this. Underneath demonstrate the direct creation method. \PhpOffice\PhpSpreadsheet\Writer\IWriter instance:ĭirect creation via \PhpOffice\PhpSpreadsheet\IOFactory. \PhpOffice\PhpSpreadsheet\Reader\IReader or The PhpSpreadsheet API offers multiple methods to create a \PhpOffice\PhpSpreadsheet\Writer\IWriter. Implementations of \PhpOffice\PhpSpreadsheet\Reader\IReader and Reading and writing to a persisted storage is not possible using the base PhpSpreadsheet classes.įor this purpose, PhpSpreadsheet provides readers and writers, which are As you already know from the architecture,
