phpexcel

PHPExcel导出功能

筅森魡賤 提交于 2019-12-30 03:52:09
对于第一次弄这个导出,总结下思路: 1.下载在http://phpexcel.codeplex.com/下载最新PHPExcel放到Vendor下,注意位置:ThinkPHP\Extend\Vendor\PHPExcel\PHPExcel.php。 2.后台控制器代码: <?php namespace Cloudtube\Controller; //活动管理 class EventsController extends FatherController { //导出模版 public function index(){ $this->display('Events/index'); } //导出Excel function expUser(){//导出Excel header("Controller:text/html;Charset=UTF-8"); $xlsName = "测试导出"; $xlsCell = array( array('member_id','账号序列'), array('uname','名字'), array('sex','性别') ); $xlsModel = M('members'); $xlsData = $xlsModel->where(1)->Field('member_id,uname,sex')->limit(1,10)->select();

Read only specific sheet

大憨熊 提交于 2019-12-30 03:50:09
问题 I am trying to read just one sheet from an xls document and I have this: $objPHPExcel = $objReader->load('daily/' . $fisierInbound); $objWorksheet = $objPHPExcel->setActiveSheetIndex(0); foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { $worksheetTitle = $worksheet->getTitle(); $highestRow = $worksheet->getHighestRow(); // e.g. 10 $highestColumn = $worksheet->getHighestColumn(); // e.g 'F' $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); $dataCalls =

How can I join Excel documents using PHPExcel?

一曲冷凌霜 提交于 2019-12-30 01:08:07
问题 I'm using PHPExcel to dynamically generate order receipts. I'd like to be able to generate a "summary" Excel file, containing all the order receipts (one per worksheet). Is there a way to "join" two (or more) Excel documents into one with PHPExcel ? 回答1: In Excel, "tabs" are known as "worksheets". You can create an Excel workbook with multiple worksheets in PHPExcel. For reference, another answer on SO has an easy-to-follow guide on how to add additional Worksheets to an existing workbook.

使用PhpSpreadsheet导出Excel文件

孤街浪徒 提交于 2019-12-29 22:12:50
最近接到个新需求:导出一个包含多个sheet的Excel文件。 本打算用PHPExcel,然后查了一下 发现PHPExcel已经不再维护,PhpSpreadsheet是PHPExcel的下一个版本,那么暂时就用它实现新需求吧。 GitHub: https://github.com/PHPOffice/PhpSpreadsheet 直接上源码: <?php namespace frontend\controllers; use Yii; use yii\web\Controller; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Style\Border; /** * 导出Excel */ class ExcelController extends Controller { public function actionIndex($id=0) { $data = [ ['title_A' => 'A', 'title_B' => 'B', 'title_C' => 'C', 'title_D' => 'D', 'title_E' => 'E', 'title_F' => 'F', 'title_G' => 'G

phpExcel write long number in cell

混江龙づ霸主 提交于 2019-12-29 04:23:24
问题 While writing the excel file is fine I see that really long numbers are formulas in excel Example: 8.71129E+12 instead of: 1234567890 How can I change the format during the PHP Excel Creation? I'm following the simple example here 回答1: $objPHPExcel->getActiveSheet()->setCellValueExplicit('A1', '1234567890', PHPExcel_Cell_DataType::TYPE_STRING); 回答2: Either set the value explicitly as a string, or set a number format mask for the cell that forces display of all digits (e.g. '#,##0' 0r '0')

Workaround for copying style with PHPExcel

自作多情 提交于 2019-12-28 13:37:11
问题 I want to copy the style information from cells to ranges, like Format Painter in Excel. The documentation says to do something like this: $activeSheet->duplicateStyle($activeSheet->getStyle('A1'), 'D1:D100'); $activeSheet->duplicateStyle($activeSheet->getStyle('B1'), 'E1:E100'); There appears to be a bug because both D1:D100 and E1:E100 get the style from cell B1. If I change the order of the two lines, both ranges get the style from A1. Similarly, $styleA = $activeSheet->getStyle('A1');

Workaround for copying style with PHPExcel

三世轮回 提交于 2019-12-28 13:36:13
问题 I want to copy the style information from cells to ranges, like Format Painter in Excel. The documentation says to do something like this: $activeSheet->duplicateStyle($activeSheet->getStyle('A1'), 'D1:D100'); $activeSheet->duplicateStyle($activeSheet->getStyle('B1'), 'E1:E100'); There appears to be a bug because both D1:D100 and E1:E100 get the style from cell B1. If I change the order of the two lines, both ranges get the style from A1. Similarly, $styleA = $activeSheet->getStyle('A1');

PHPExcel读取excel文件示例

会有一股神秘感。 提交于 2019-12-27 12:05:34
PHPExcel读取excel文件示例 PHPExcel最新版官方下载网址: http://phpexcel.codeplex.com/ PHPExcel是一个非常方便生成Excel格式文件的类,官方下载包中带有大量如何生成各种样式excel文件的示例,但没有一个读取Excel文件的完整例子,下面是读取的例子: 读取Excel的内容主要有两个选择:PHPExcelReader、PHPExcel。 PHPExcelReader比较轻量级,仅支持Excel的读取,实际上就是一个Reader。但是可惜的是不能够支持Excel 2007的格式(.xlsx)。 PHPExcel比较强大,能够将内存中的数据输出成Excel文件,同时还能够对Excel做各种操作,下面主要介绍下如何使用PHPExcel进行Excel 2007格式(.xlsx)文件的读取。 下载PHPExcel后保存到自己的类文件目录中,然后使用以下代码可以打开Excel 2007(xlsx)格式的文件: require_once '/libs/PHPExcel-1.8.0/Classes/PHPExcel.php'; //修改为自己的目录 echo '<p>TEST PHPExcel 1.8.0: read xlsx file</p>'; $objReader = PHPExcel_IOFactory:

Export and download query results to Excel file in PHP from oracle

只愿长相守 提交于 2019-12-25 14:25:39
问题 // Export results require_once('PHPExcel.php'); $query = "SELECT DISTINCT TITLE, PID, TYPE, SUM(DAYCOUNT) AS tot, ROUND(SUM(DAYCOUNT)/( SELECT SUM(DAYCOUNT) FROM REPORT_LIST_VIEW), 4) AS per FROM REPORT_LIST_VIEW WHERE DAYCOUNT > '0' GROUP BY TITLE, PID, TYPE ORDER BY tot DESC"; if ($result = db_query($query)) { // Create a new PHPExcel object $objPHPExcel = new PHPExcel(); $objPHPExcel->getActiveSheet()->setTitle('List of Cities'); // Loop through the result set $rowNumber = 1; while ($row =

PHPExcel unable to read file

◇◆丶佛笑我妖孽 提交于 2019-12-25 07:59:40
问题 I'm using CakePHP 3.2 and PHPExcel library to import data from excel sheet to database. I have the library at /vendor/PHPExcel/Classes/PHPExcel.php /vendor/PHPExcel/Classes/PHPExcel/IOFactory.php and the action in controller is public function bulkUpload() { $inputFileName = $this->request->data('excel_data'); //debug($inputFileName['name']); if ($inputFileName != '') { $inputFileType = \PHPExcel_IOFactory::identify($inputFileName); $objReader = \PHPExcel_IOFactory::createReader(