phpexcel

Reading very large (more than 100MB) Excel files in PHP

一曲冷凌霜 提交于 2020-01-13 09:45:12
问题 I'm trying to read a larger than 100MB Excel file using PHPExcel but it crashes while loading the file. I don't need any styling. I tried using: $objReader->setReadDataOnly(true); but it still crashes. Is there any efficient way to read this size of Excel file in PHP? 回答1: Try Spout: https://github.com/box/spout. This is a PHP library that was created to solve your problem (reading/writing large files). Here is why it works: Other libraries keep a representation of the spreadsheet in memory

Error while opening an Excel file that generated using phpExcel

南楼画角 提交于 2020-01-11 14:15:11
问题 I am trying to generate an Excel file using phpExcel library in Codeigniter . The problem is that while downloading the file it shows characters in in undifined formats While opening the downloaded file it shows the message that is an different format, please refer the pic and while opening the file content as and my code stuff is: if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $this->load->library('excel'); $sheet = new PHPExcel(); $objWorkSheet = $sheet->createSheet();

PHPExcel throws Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes)

老子叫甜甜 提交于 2020-01-11 11:14:33
问题 I am using PHPExcel (found here: https://github.com/PHPOffice/PHPExcel). If i try to read more than approximately 2000 rows then it shows memory error as follows. Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /home/sample/PHPExcelReader/Classes/PHPExcel/worksheet.php on line 89 My Excel data range is A1:X2000 Below is my code used to read the excel. ini_set('memory_limit', '-1'); /** Include path **/ set_include_path(get_include_path() . PATH

PHPExcel Warning: ZipArchive::getFromName(): Invalid or unitialized Zip object in

浪子不回头ぞ 提交于 2020-01-11 07:18:32
问题 I'am trying to read xlsx file, but I get this error: Warning: ZipArchive::getFromName(): Invalid or unitialized Zip object in E:\wamp\www\test\Classes\PHPExcel\Reader\Excel2007.php on line 323 what this error mean? 回答1: I had the same error and it was due to improper permissions. Try doing a simple fopen() to make 100% sure you can read that file from the given directory. Also, make sure you can read that file successfully if it's in the same directory as your script so you know the file

How to set auto-line break PhpExcel?

三世轮回 提交于 2020-01-11 06:44:07
问题 I'm using PHPExcel to generate some excel export. Excel has an autoline break feature. How can i activate this ? My customer use only Microsoft Excel, so it don't have to support others programs. Any ideas ? I may use something like this : how to make New lines in a cell using phpexcel But that's more a kind of hack, than a real solution. UPDATE : See, once columns are merged, wrap text fail. I tryied to add wrap text upon every column merged, but it don't affect result. UPDATE 2 : The cells

PHPExcel gets wrong timezone even after setting date_default_timezone_set

戏子无情 提交于 2020-01-11 06:31:48
问题 I'm using http://phpexcel.codeplex.com in one of my project, and I have come into an issue. I want to write the time() value inside a cell, which I am doing with : function writeTimeLine($objActiveSheet, &$lineNumber, $timeStart, $timeEnd, $duration, $category, $client, $date, $comment) { $objActiveSheet->setCellValue('A'.$lineNumber, PHPExcel_Shared_Date::PHPToExcel( $timeStart )); $objActiveSheet->getStyle('A'.$lineNumber)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat:

PHPExcel - How can i read the Excel sheet row by row

家住魔仙堡 提交于 2020-01-09 11:32:11
问题 How can i read Excel worksheet row by row using PHPExcel? I have a sheet contains more than 100000 rows, but i want to read only 500 rows. $sheetData = $objPHPExcel->getActiveSheet(); $highestRow = $sheetData->getHighestRow(); $highestColumn = $sheetData->getHighestColumn(); $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); echo '<table>'; for ($row = 1; $row <= $highestRow; ++$row) { echo '<tr>'; for ($col = 0; $col <= $highestColumnIndex; ++$col) { echo '<td>' .

ERROR_MESSAGE_MAIN ERROR_MESSAGE_REASON on iPad and iPhone Safari

送分小仙女□ 提交于 2020-01-07 07:16:06
问题 My website has a functionality of downloading excel sheet. I'm using PHPExcel library with Codeigniter to create the .xlsx sheet. It works fine almost everywhere but in iPad/ iPhone Safari. The following error covers the screen. Safari Error Screenshot My code to download the file is following: ob_end_clean(); $filename='attendance_list.xlsx'; header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="'.$filename.'"'); header('Cache-Control: max-age=0'

PHPExcel - Set cells as string while uploading from Array

时间秒杀一切 提交于 2020-01-07 04:44:06
问题 $objPHPExcel->getActiveSheet()->fromArray($dataArray,null,"A2") I've the above line of code. The problem is, I am not good at iterating and I want all the cell values to be set as STRING so as to avoid automated modifications of texts leading zeros. P.S. In Addition, code for setting as STRING for selective columns will be appreciated. Thanks! 回答1: When you set cell values individually, you have the option of setting the datatype explicitly, but when you use the fromArray() method, you don't

No data is written into Excel

走远了吗. 提交于 2020-01-06 23:45:08
问题 I have the following code: require 'PHPExcel.php'; require 'PHPExcel/Writer/Excel2007.php'; require 'PHPExcel/IOFactory.php'; $user = "root"; $pass = "admin"; $host = "localhost"; $db = "hrtms"; $objPHPExcel = new PHPExcel(); try{ $con = new PDO("mysql:host=$host;dbname=$db",$user,$pass); $con->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $con->exec('SET NAMES "utf8"'); } catch(PDOException $e){ echo $e->getMessage(); exit(); } try{ $query = $con->prepare("SELECT * FROM emptb WHERE