phpexcel

PHPExcel how to set cell value dynamically

痴心易碎 提交于 2019-12-17 22:06:00
问题 How to set cell/column value dynamically using PHPExcel library? I am fetching result set from MySQL database and I want to write data in excel format using PHPExcel library. Looking at example $objPHPExcel->getActiveSheet()->setCellValue('A1', 'cell value here'); indicates that we have to hard code cell/column reference As 'A1', then it writes to cell/column A1. How I can increment cell/column and/or row reference based on rows and corresponding column values from result set? Please guide.

PHPexcel cannot reads styles from xls

空扰寡人 提交于 2019-12-17 21:32:43
问题 I cannot read styles from xls by PHPexcel. I browsing for a solution a lot but everywhere writes solutions for write xls but I like it to read. I like especially strikethrough but it cannot reads neither this nor any other style informations. My code is the following, this reads all data correctly but nothing more. Im sure to make text styled in the xls. require_once 'PHPExcel.php'; $filepath = "path/to/your/xls/file.xls"; $inputFileType = PHPExcel_IOFactory::identify($filepath); $objReader =

PHPExcel: Download the Excel file on the client side

Deadly 提交于 2019-12-17 20:04:20
问题 The problem was solved: For other users that may have this problem - notice the encoding of the PHP file. If you use PHPExcel it must be ANSII encoding and not UTF8, otherwise the EXCEL will be downloaded corruptly. The Headers that were added (answer 1) solved the problem after i changed the encoding of the file itself. I am using PHPExcel in order to create an EXCEL from a table in MYSQL DB, so the user can download it to his computer. The code bellow creates a correct Excel file but the

ThinkPHP中使用PHPExcel导入Excel

夙愿已清 提交于 2019-12-17 20:03:27
下载PHPEXCEL 后放到项目里。 public function InExcel() { //设定缓存模式为经gzip压缩后存入cache(PHPExcel导入导出及大量数据导入缓存方式的修改 ) $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip; $cacheSettings = array(); PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); $objPHPExcel = new PHPExcel(); //读入上传文件 if ($_POST) { $objPHPExcel = PHPExcel_IOFactory::load($_FILES["inputExcel"]["tmp_name"]); //内容转换为数组 $indata = $objPHPExcel->getSheet(0)->toArray(); //print_r($indata); //excel sheet个数 //echo $objPHPExcel->getSheetCount(); //把数据新增到mysql数据库中 $arr = array(); $j = 0; $model = D('goods_unit'

how to get date from excel using PHPExcel library

风流意气都作罢 提交于 2019-12-17 15:35:04
问题 I am trying to get Date from excel using PHPExcel. But I am not getting date, I am getting string value which is not seconds from 1970 . Code I have tried is $InvDate=trim($excel->getActiveSheet()->getCell('B' . $i)->getValue()); 回答1: Try use $cell = $excel->getActiveSheet()->getCell('B' . $i); $InvDate= $cell->getValue(); if(PHPExcel_Shared_Date::isDateTime($cell)) { $InvDate = date($format, PHPExcel_Shared_Date::ExcelToPHP($InvDate)); } P.S. @DiegoDD: Should mention that $format is the

Why PHPExcel does not allow to write more than 5000 rows

喜欢而已 提交于 2019-12-17 12:35:05
问题 Can any one please tell me Why PHPExcel does not allow more than 5000 rows. I am using an open-source PHPExcel for report generation on my projects and i could not write more than 5000 rows of data from Mysql-DB. My result set fetch 7230 records when the query is executed. How do i fix it.. 回答1: Almost certainly this is a timeout or a memory issue. The only PHPExcel limit for worksheets size is 65,536 rows and 256 (IV) columns (when using the Excel5 Writer); or 1,048,576 rows and 16,384 (XFD)

PHPExcel及Mpdf导出

纵饮孤独 提交于 2019-12-17 09:43:09
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> PHPExcel常用操作 #导入类库 require_once 'PHPExcel/Classes/PHPExcel.php'; require_once 'PHPExcel/Classes/PHPExcel/Writer/Excel5.php'; //Office 03格式写类 require_once 'PHPExcel/Classes/PHPExcel/Writer/Excel2007.php'; //Office 07格式写类 #基础操作 $objPHPExcel = \PHPExcel_IOFactory::load('a.xls'); //读入指定excel文件 $objPHPExcel->setActiveSheetIndex(0); //指定活动工作表 $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('宋体'); $objPHPExcel->getProperties()->setTitle('xxx'); #单元格写入 $objPHPExcel->getActiveSheet()->setCellValue('A3', 'xxx'); //设定A3单元格值为xxx #单元格合并 $objPHPExcel

PHPExcel auto size column width

一世执手 提交于 2019-12-17 08:16:13
问题 I'm trying to auto size the columns of my sheet. I'm writing the file and in the end I try to resize all of my columns. // Add some data $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('B1', 'test1111111111111111111111') ->setCellValue('C1', 'test1111111111111') ->setCellValue('D1', 'test1111111') ->setCellValue('E1', 'test11111') ->setCellValue('F1', 'test1') ->setCellValue('G1', 'test1'); foreach($objPHPExcel->getActiveSheet()->getColumnDimension() as $col) { $col->setAutoSize(true); }

PHPExcel Accounting Formats

只愿长相守 提交于 2019-12-14 03:43:41
问题 I'm working with PHPExcel and I'm trying to format a cell using Excel's built-in "Accounting" format. I'm aware of the Format Code: PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE But this simply formats to two decimal places and adds a $ in front of the number. The result I'm looking for is the right aligned cell with the $ on the left. $0 values should be listed as "-" and negative values should be $ (1.11) As far as I can tell there are no other currency formats in the

How can I read Excel files with symfony2?

偶尔善良 提交于 2019-12-14 03:36:44
问题 I installed Excelbundle with PhpExcel library. I want to read excel files I found this function. How can I use it? Any suggestion? public function xlsAction() { $filenames = "your-file-name"; $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($filenames); foreach ($phpExcelObject ->getWorksheetIterator() as $worksheet) { echo 'Worksheet - ' , $worksheet->getTitle(); foreach ($worksheet->getRowIterator() as $row) { echo ' Row number - ' , $row->getRowIndex(); $cellIterator = $row-