phpexcel

写一个excel导入加过滤

不羁岁月 提交于 2020-01-25 13:15:07
//首先引入bootstrap 来作为样式 <button class="btn btn-info" type="button" id="import" data-toggle="modal" data-target="#myModal">导入</button> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">导入</h4> </div> <div class="modal-body"> <div>导入格式如下 <a href="/public/yuangongmoban.xls" download="员工导入模板.xls"

How to close excel file in php-excel-reader

大兔子大兔子 提交于 2020-01-25 10:26:07
问题 I am reading two excel file, using php-excel-reader (From this) After reading two files of 1st row, I am comparing it. If they are same then I am appending contain of on file to other. To write the file I am using this Now for doing this I want to close one file, but that function is not available in php-excel-reader here is my code compare file { $data = new Spreadsheet_Excel_Reader($filepath); $data1 = new Spreadsheet_Excel_Reader($destinationfilepath); } unset($data); unset($data1); if(

How to generate a password protected spreadsheet from PHP?

末鹿安然 提交于 2020-01-24 07:21:52
问题 How to generate a password protected spreadsheet from PHP ? I tried PHPExcel library from http://phpexcel.codeplex.com/ PHPExcel offers 3 levels of “protection”: document security, sheet security and cell security. Document security allows you to set a password on a complete spreadsheet, allowing changes to be made only when that password is entered. But user can open the spreadsheet and view the contents without password. And I tried Spreadsheet_Excel_Writer as well, but did not find any

PHP实现Excel导入

不羁的心 提交于 2020-01-23 23:57:42
public function addUdid() { if (!empty($_FILES)){ ini_set('memory_limit','256M'); $ upload = new \Think\Upload(); // 实例化上传类 $upload->maxSize = 10485760 ; // 设置附件上传大小 $upload->exts = array('xls','xlsx'); // 设置附件上传类型 $upload->rootPath = './Public/Excel/'; // 设置附件上传根目录 $upload->autoSub = false; // 将自动生成以photo后面加时间的形式文件夹,关闭 // 上传文件 $info = $upload->upload(); // 上传文件 $exts = $info['file']['ext']; // 获取文件后缀 $filename = $upload->rootPath.$info['file']['savename']; // 生成文件路径名 if(!$info) { // 上传错误提示错误信息 $this->error($upload->getError()); }else{ // 上传成功 Vendor('PHPExcel'); $PHPExcel = new \PHPExcel();

Set cell value using PHPExcel and setCellValue method

微笑、不失礼 提交于 2020-01-17 05:33:06
问题 I'm trying to set|persist some values in a Excel (.xlsx) file and I'm using phpoffice/phpexcel library. This is how my code looks: $objReader = \PHPExcel_IOFactory::createReader('Excel2007'); $objPHPExcel = $objReader->load($filename); $objWorksheet = $objPHPExcel->getActiveSheet(); $objPHPExcel->getActiveSheet()->setCellValue('A'.$cRow, $hcpId); // set column A - HCP.ID - value $objPHPExcel->getActiveSheet()->setCellValue('B'.$cRow, $terrID); // set column B - TERRITORY.ID - value

Days since 1900

喜夏-厌秋 提交于 2020-01-15 02:54:25
问题 I'm using data from Excel2007 as parsed by PHPExcel, and dates come out as days since 1900. How can I convert to string of YYYY-MM-DD (or anything similar)? 回答1: Or use $phpDate = PHPExcel_Shared_Date::ExcelToPHP($cell->getCalculatedValue()); to convert an Excel/PHPExcel date to a PHP date/timestamp, and then use standard PHP date() function for formatting 回答2: Something like this, should do the trick: PHPExcel_Style_NumberFormat::toFormattedString($cell->getCalculatedValue(), 'YYYY-MM-DD');

PHPExcel reading too slow

不打扰是莪最后的温柔 提交于 2020-01-14 18:56:19
问题 I know, there are lot's of questions here sbout improving PHPExcel performance. But all of them are about writing data, and my problem is in reading . My function: function parse($filename){ $objPHPExcel = PHPExcel_IOFactory::load($filename); $activeSheet = $objPHPExcel->getActiveSheet(); $parsedData = array(); $columnHeaders = array('order', 'ts', 'summ', 'name', 'quant', 'price', 'bccu'); foreach ($activeSheet->getRowIterator() as $rkey => $row) { $cellIterator = $row->getCellIterator();

How do I use PHPExcel to read data from an Excel file?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-14 13:57:40
问题 I want to read data from an Excel file in PHP so that I can process the data and insert it into a DB. Looking around SO, it looks like PHPExcel is the premier library for this task. I went to the PHPExcel GitHub page (https://github.com/PHPOffice/PHPExcel), but I cannot figure out how to actually use the library. There are a ton of example files and none of the ones I looked at seem to match the simple use case I'm looking for. Furthermore, I cannot even figure out which files from the GitHub

Why PHPexcel insert single quote in date field?

别来无恙 提交于 2020-01-14 09:23:31
问题 I'm trying to insert date into the cell using PHPExcel. This is my code: include('xlsx/Classes/PHPExcel.php'); include('xlsx/Classes/PHPExcel/Calculation.php'); include('xlsx/Classes/PHPExcel/Cell.php'); $objPHPExcel = new PHPExcel(); $start = 3; $objPHPExcel->getActiveSheet()->getStyle('A1')->getNumberFormat()->setFormatCode('DD.MM.YYYY'); $objPHPExcel->getActiveSheet()->SetCellValue('A1', date('d.m.Y', time()+60*($start + 3))); $objPHPExcel->getActiveSheet()->getStyle('A1')->getNumberFormat

PHPExcel Style getting default number format

别说谁变了你拦得住时间么 提交于 2020-01-13 10:26:10
问题 I have the following code $xl = new PHPExcel(); $sheet = xl->setActiveSheetIndex(0) $sheet->getStyle('A')->getNumberFormat()->setFormatCode('#,##0.00'); $format = $sheet->getStyle('A')->getNumberFormat()->getFormatCode(); I'd expect $format to contain #,##0.00 but it contains General . Am I missing something? PHPExcel v. 1.7.6 回答1: PHPExcel does not support row or column styles: styles are applied to cells $sheet->getStyle('A1')->getNumberFormat()->setFormatCode('#,##0.00'); or to ranges of