V
V
Vladimir2019-03-28 14:09:40
PHP
Vladimir, 2019-03-28 14:09:40

To in the PHPExcel library to load the file contained in the variable?

<?
require_once "xls/Classes/PHPExcel.php";

$file = file_get_contents("name_file.xlsx");
$pExcel = PHPExcel_IOFactory::load($file);
$objWriter = PHPExcel_IOFactory::createWriter($pExcel, 'Excel5');
$objWriter->save('name_file' . '.xls');

Here's how it doesn't work in the example now? since the PHPExcel_IOFactory::load method asks for the path and not the content itself, and I need to transfer the content in the $file variable

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kadetBigler, 2019-03-28
@kadetBigler

Why read the content first and then push it into phpexcel if it has its own data reading method?
And another point: you are reading an xlsx file, and you are trying to process it as Excel5 (this is the old xls format)

require_once 'Classes/PHPExcel/IOFactory.php';
    $file='name_file.xlsx';
    $objReader = PHPExcel_IOFactory::createReader('Excel2007');
    $xls = $objReader->load($file);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question