Add php files
This commit is contained in:
62
modules/EcmProducts/cards/import.php
Executable file
62
modules/EcmProducts/cards/import.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
ini_set('memory_limit', '2048M');
|
||||
date_default_timezone_set('Europe/London');
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #01</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #01</h1>
|
||||
<h2>Simple File Reader using PHPExcel_IOFactory::load()</h2>
|
||||
<?php
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '/cards/');
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'modules/EcmProducts/cards/PHPExcel/IOFactory.php';
|
||||
$inputFileName = './lista.xls';
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
|
||||
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
|
||||
echo '<hr />';
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
$i = 0;
|
||||
foreach ($objPHPExcel->getActiveSheet()->getDrawingCollection() as $drawing) {
|
||||
if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
||||
ob_start();
|
||||
call_user_func(
|
||||
$drawing->getRenderingFunction(),
|
||||
$drawing->getImageResource()
|
||||
);
|
||||
$imageContents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
switch ($drawing->getMimeType()) {
|
||||
case PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_PNG :
|
||||
$extension = 'png'; break;
|
||||
case PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_GIF:
|
||||
$extension = 'gif'; break;
|
||||
case PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_JPEG :
|
||||
$extension = 'jpg'; break;
|
||||
}
|
||||
} else {
|
||||
$zipReader = fopen($drawing->getPath(),'r');
|
||||
$imageContents = '';
|
||||
while (!feof($zipReader)) {
|
||||
$imageContents .= fread($zipReader,1024);
|
||||
}
|
||||
fclose($zipReader);
|
||||
$extension = $drawing->getExtension();
|
||||
}
|
||||
$myFileName = '00_Image_'.++$i.'.'.$extension;
|
||||
file_put_contents($myFileName,$imageContents);
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user