phpexcel

PhpExcel create sheet for each result row PHP MySQL

心不动则不痛 提交于 2019-12-11 10:39:17
问题 I have a question regarding creating one excel file only with PhpExcel, but many worksheets (or whatever you call the extra sheets all inside 1 excel file). I am trying to export my php mysql data using phpexcel into excel file xlsx. There is a fair amount of data in my database. I would like to export data in each row in a separate worksheet inside the same excel file. For example, in my database 1 John Doe aaa@bbb.com 2 James Citizen zzz@xxx.com 3 ... 4 ... 5... ... and so on I would like

PHPExcel - format for the column

亡梦爱人 提交于 2019-12-11 08:33:40
问题 I need to set for all columns format: FORMAT_NUMBER I can do it for one cell. But I can not do for the whole column B. $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER); How to set the entire column B? PHPExcel_Style_NumberFormat :: FORMAT_NUMBER 回答1: You can set styling for an individual cell, or for a range of cells; but not for a column or a row. To set the style for a range, use $objPHPExcel->getActiveSheet() -

Convert HTML to Excel Rich Text and vice versa

岁酱吖の 提交于 2019-12-11 08:18:12
问题 I'm using PHPExcel for transferring data between MySQL DB and Excel 2007 worksheets. It works well on most situations, but I encountered one problem. Some of the fields in DB contain HTML data. I need to preserve the formatting in Excel cells as much as possible. As I could figure out, Excel allows the following formatting inside cells ( PHPExcel_RichText class supports all of these): new lines [these can be used to track <p></p> blocks], font name, size, color, bold, italic, underline,

how to read 09/09/2017 exactly from xls using php?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 07:41:16
问题 var_dump($objPHPExcel->getActiveSheet()->getCell('B2')->getValue()); i tried the above code and i get "float(42987)" as output. i just want the exact value of that cell! var_dump($objPHPExcel->getActiveSheet()->getCell('C2')->getValue()); when i execute this i get the correct value "2017/09/12" so how will i get the data's in this "09/09/2017" format from xls? EDIT 1 : the data cannot be predicted ! it can be a string or date with different formats ! example : B2 can be 'string','09/09/2017',

How to set color for cell phpexcel into foreach loop

我怕爱的太早我们不能终老 提交于 2019-12-11 06:43:39
问题 Now I want set text color for cell in phpexcel into foreach loop. The foreach loop is something like : $redBold = array( "font" => array( "bold" => true, "color" => array("rgb" => "FF0000"), ), ); $row = 5; $count = 0 foreach ($data as $key => $value) { $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count++, $row, $value['type']?$value['type']:0); if ($value['type'] == 1) { $objPHPExcel->getActiveSheet()->getStyle($count . $row)->applyFromArray($redBold); } } this code is not

PHPExcel: Combine 2 Excel files into 1 into the same worksheet

泄露秘密 提交于 2019-12-11 05:59:14
问题 I have 2 excel files birds.xlsx and bees.xlsx both of which have the same number of columns and same type of column header. I've seen how PHPExcel does wonders with excel files but is there some way to combine 2 separate files into the same worksheet and saving it as a new file? The analogy that comes to mind is something like the SQL UNION command. 回答1: Something like: // Load both spreadsheet files $objPHPExcel1 = PHPExcel_IOFactory::load("birds.xlsx"); $objPHPExcel2 = PHPExcel_IOFactory:

codeplex phpexcel validation issue for invalid values

北慕城南 提交于 2019-12-11 04:56:06
问题 Here's my problem, I have a validation in one of my excel. $objValidation = $sheet->getCell('G17' )->getDataValidation(); $objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_DECIMAL ); $objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION ); $objValidation->setOperator( PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL); $objValidation->setAllowBlank(true); $objValidation->setShowInputMessage(true); $objValidation->setShowErrorMessage(true);

Class 'PHPExcel' not found in../HTML.php on line 153

 ̄綄美尐妖づ 提交于 2019-12-11 04:34:09
问题 I'm having a difficult time getting PHPExcel to work. In the class HTML.php, where the object is declared, $objPHPExcel = new PHPExcel(); (on line 153), it can't seem to load PHPExcel. The entire error is: Fatal error: Class 'PHPExcel' not found in /home/main/public_html/home/IEW/PHPExcel/Reader/HTML.php on line 153 The PHPExcel Library is located at /home/main/public_html/home/IEW/PHPExcel/ (My host is GoDaddy with cpanel is that makes any sort of difference). Thanks! 回答1: For PHPExcel to

PHPExcel: How to use insertNewRowBefore function correctly?

谁都会走 提交于 2019-12-11 03:54:06
问题 I want to add $x rows after line number $insert_here. This is the function: // Get the Excel file I want to work on: function get_excel_file(){ // Need to define this to change a global variable inside a function global $objPHPExcel; // Define an Exel Object to read files from: $objPHPExcel = PHPExcel_IOFactory::load('keywords.xlsx'); } // Inserts new rows: Gets the number of rows to insers them before the second variable function insert_rows( $objPHPExcel, $insert_here, $num_rows ){ echo

How to add dropdown list control using PHPExcel

梦想与她 提交于 2019-12-11 03:19:23
问题 How can I add default dropdown in excel sheet using PHPExcel when user add a new row example available for individual cell not for a column or multiple columns. Example of Excel Template SL No. | First Name | Middle Name | Last Name | Class | Sec | DOB | Father Name | Selected Class and Sec require dropdown. Hence when a new student record is added class and sec column should have dropdown. Is it possible through PHPExcel. If someone could provide a tutorial or something, that would be a real