phpexcel

PHPExcel how to apply alignment for the whole document created from mysql table

三世轮回 提交于 2020-01-01 08:39:27
问题 I used PHPExcel library to generate excel files based on the table created by the mysql query. I created multiple tabs with individual data from different queries. I need to align the data in the all the cells in all the tabs (worksheets) to center. This is my code: $mysql_xls = new MySqlExcelBuilder($mysql_db,$mysql_user,$mysql_pass); // Add the SQL statements to the spread sheet $tab_name = "tabname"; $mysql_xls->add_page($tab_name,$sql_statement,NULL,'A',1); $phpExcel = $mysql_xls-

PhpExcel - How insert the same row after row N?

北战南征 提交于 2020-01-01 08:37:06
问题 I have php template. this is a empty table (T0 rows) with some footer at the bottom. From php i try to fill the table, but if i had T1 rows (T1 > T0) then trouble appers. I beleve that empty table should contains one empty row. And we know this row number. Then we copy this row (insert the same rows) T1 times and fill empty table. Footer goes down. And everything will be ok Give me an example, how i can do this. Thank you. PhpExcel 1.7.6 回答1: Just copying what @markBaker said (so that we can

How to set active sheet without loading an xlsx file?

你说的曾经没有我的故事 提交于 2020-01-01 03:26:11
问题 I am using PHPExcel to generate an xl using php. I am not loading an xl sheet but creating new sheets using $phpExcel = new PHPExcel(); $phpExcel->getActiveSheet()->setTitle("My Sheet"); I want to set active sheet using phpExcel using $phpExcel->setActiveSheetIndexByName("2"); but im getting an error setActiveSheetIndexByName not defined function. Please help 回答1: You do, of course, need to create/add additional worksheets to be able to change the active sheet: using new PHPExcel() will only

How to read data from excel using with PHPExcel

∥☆過路亽.° 提交于 2020-01-01 03:23:08
问题 I am trying to import data from excel sheet(.xlsx). I have found PHPExcel for import data but after downloading document and source code I am confused which file is important for me. I also tried to find out document on that site but not found the way. About my task: Read excel sheet data from selected sheet and insert data to my database table. So I really thankful If You will guide me how to use it. Thanks. 回答1: You can use the PHPExcel library to read an Excel file and insert the data into

How to get phpexcel to keep leading 0s in phone numbers?

时光总嘲笑我的痴心妄想 提交于 2020-01-01 02:41:11
问题 Here's the code i'm using right now to set the cell values. It works alright if the number has separators like . or / but when there's no separator it gets saved as int and the leading 0 is stripped $sheet->setCellValue($letter[$j].$row_nr,$entity['Phone'], PHPExcel_Cell_DataType::TYPE_STRING); 回答1: Either: // Set the value explicitly as a string $objPHPExcel->getActiveSheet()->setCellValueExplicit('A1', '0029', PHPExcel_Cell_DataType::TYPE_STRING); or // Set the value as a number formatted

PHPExcel - How to set a url

风流意气都作罢 提交于 2019-12-31 20:15:15
问题 I am isung PHPExcel and have a URL in a string. When doing: $url = 'http://dx.doi.org/10.1016/j.phymed.2005.11.003' $xls = new PHPExcel(); $xls->setActiveSheetIndex(0); $xls->getActiveSheet()->setCellValueByColumnAndRow(1,2,$url); The url is set as simple text. I also tried: $xls->getActiveSheet()->getCellByColumnAndRow(1,2)->getHyperlink()->setUrl('"'.$url.'"'); But then, when clicking on the link, it tries to open a local folder. Any idea how to do that? Thank you. EDIT When I try do do

how i can import an excel file using php and print it in a html table

落爺英雄遲暮 提交于 2019-12-31 04:09:52
问题 i try to use phpoffice/phpexcel to do this but i haven't an idea of do it... i have this form in html <body> <div align="center">ELENCA TABELLE PRESENTI NEL DB</div> <form action="index.php" method="post" enctype="multipart/form-data"> <table> <tr> <td> Filename: </td> <td> <input type="file" name="file" id="file"> </td> </tr> <tr> <td colspan="2" align="right"> <input type="submit" name="submit" value="Submit"> </td> </tr> </table> </form> <script src="https://cdnjs.cloudflare.com/ajax/libs

使用PHPExcel 对表格进行,读取和写入的操作。。。。

孤街浪徒 提交于 2019-12-30 05:53:00
下面的代码是使用PHPExcel 对多个表格数据进行读取, 然后整合的写入新的表格的方法!!!代码有点粗糙 , 多多保函!!! 这里有些地方注意下,如果你的表格数据过大, 一定要记得修改php.ini里面的相关配置: file_uploads = on ;是否允许通过HTTP上传文件的开关。默认为ON即是开 upload_tmp_dir ;文件上传至服务器上存储临时文件的地方,如果没指定就会用系统默认的临时文件夹 upload_max_filesize = 8m ;望文生意,即允许上传文件大小的最大值。默认为2M post_max_size = 8m ;指通过表单POST给PHP的所能接收的最大值,包括表单里的所有值。默认为8M 一般地,设置好上述四个参数后,上传<=8M的文件是不成问题,在网络正常的情况下。 但如果要上传>8M的大体积文件,只设置上述四项还一定能行的通。 进一步配置以下的参数 max_execution_time = 600 ;每个PHP页面运行的最大时间值(秒),默认30秒 max_input_time = 600 ;每个PHP页面接收数据所需的最大时间,默认60秒 memory_limit = 8m ;每个PHP页面所吃掉的最大内存,默认8M 把上述参数修改后,在网络所允许的正常情况下,就可以上传大体积文件了 max_execution_time = 600

PHP读取csv文件的内容

三世轮回 提交于 2019-12-30 05:18:49
我之前写过一篇 PHP读取csv文件的内容 上代码index.php <?php /** * * @author XC * */ class Excel { public $currentSheet; public $filePath; public $fileType; public $sheetIndex=0; public $allColumn; public $allRow; public function initialized($filePath) { if (file_exists($filePath)) { $this->filePath=$filePath; }else{ return array(); } //以硬盘方式缓存 $cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_discISAM; $cacheSettings = array(); PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); $file_ext=strtolower(pathinfo($this->filePath, PATHINFO_EXTENSION)); switch ($file_ext) { case 'csv':

Import excel files with image in php/mysql

安稳与你 提交于 2019-12-30 04:42:27
问题 I want to make an import script which allows users to upload their excel file (extension not important) to my php application. The application should reconize a list of items (so far so good). The difficulty in this case is that the excel files contain images... I've read information about phpexcel library but it does not say anything about images. Anybody ideas? 回答1: You can access images by PHPExcel library. For importing images: $objPHPExcel = PHPExcel_IOFactory::load("MyExcelFile.xls");