phpspreadsheet

How to Install PHPSpreadsheet in Joomla

拥有回忆 提交于 2019-12-11 16:02:59
问题 I'm wondering how to best incorporate PHPSpreadsheet into Joomla! applications, on shared hosting. With PHPExcel, you just uploaded the library. PHPSpreadsheet is using Composer, which is new to me, but looks straightforward enough. However, I see Joomla! includes it to manage dependencies in the core, but does not publish the composer.json file, and commits the /vendor subfolder. Any advice on the best way to safely add PHPSpreadsheet so its available to Joomla! extensions, without messing

phpsreadsheet create excel from html table

痴心易碎 提交于 2019-12-11 12:09:21
问题 There is no documentation for using phpspreadsheet to form an excel file from a html table. This is possible using "jquery.table2excel.js" but it seems pretty old; makes old excel files and makes warnings about the file. phpspreadsheet makes a good excel file, but I just can't find any answers to do the function. 回答1: Use the HTML Reader to read the data into a Spreadsheet, then the appropriate writer (xls or xlsx) 回答2: If you are generating an Excel file from pre-rendered HTML content you

phpspreadsheet setFormatCode not working

我只是一个虾纸丫 提交于 2019-12-11 09:26:10
问题 Sometimes I'm unable to format an Excel cell data as date using $date wiht format 'yyyy-mm-dd' (eg. 2017-07-12) if ($date != '') { $t_date = PhpOffice\PhpSpreadsheet\Shared\Date::stringToExcel($date); $sheet->setCellValueByColumnAndRow($column,$row, $t_date); $sheet->getStyleByColumnAndRow($column,$row)->getNumberFormat()->setFormatCode(PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY); } 回答1: The previous code fails when a $date is not valid (eg. 0000-00-00), and keeps

PHPSpreadsheet - Multiple tables with “format as table” in excel worksheet

醉酒当歌 提交于 2019-12-11 05:48:00
问题 I try to have multiple formatted tables in one worksheet. The template looks like following example: Template The tables are styled with table format templates. If i run the code: use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\IOFactory; $inputFileName = 'template/Age.xlsx'; $inputFileType = 'Xlsx'; if (!file_exists($inputFileName)) { echo('File ' . $inputFileNameShort . ' does not exist'); } $reader = IOFactory::createReader(

Download PhpSpreadsheet file without save it before

家住魔仙堡 提交于 2019-12-10 03:21:12
问题 I'm using PhpSpreadsheet to generate an Excel file in Symfony 4. My code is: $spreadsheet = $this->generateExcel($content); $writer = new Xlsx($spreadsheet); $filename = "myFile.xlsx"; $writer->save($filename); // LINE I WANT TO AVOID $response = new BinaryFileResponse($filename); $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); $response->setContentDisposition( ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename ); But I don't

How to use PHPSpreadsheet in CodeIgniter 3 to read data from Excel (.xlsx and .xls) file?

谁说我不能喝 提交于 2019-12-08 09:12:54
问题 Recently in one of my CodeIgniter based project, I need to read data from Excel file ( .xlsx and .xls ) and insert those data into MySQL. Unfortunately, I did not use PHPSpreadsheet before (as I did not require to work with Excel :( ). So far what I did was, download the PHPSpreadsheet from Github and extract it to the root directory of my CodeIgniter Project. PHPSpreadsheet in CodeIgniter root directory. File Structure of PHPSpreadsheet. So far I've tried to import the official docs example

laravel+PhpSpreadsheet导出excel并下载

泄露秘密 提交于 2019-12-07 09:08:17
效果图: 官方网站:https://phpspreadsheet.readthedocs.io/en/latest/#getting-started 第一步:导入phpspreadsheet 在IDE里面利用composer安装,命令如下: composer require phpoffice/phpspreadsheet 第二步:在laravel项目中使用该插件 以下这段代码的逻辑是先把需要的数据写入excel然后保存在指定目录下,在前端利用a标签点击下载excel文件 $spreadsheet = new Spreadsheet();//实例化 $spreadsheet->setActiveSheetIndex(0);//设置excel的索引 $sheet=$spreadsheet->getActiveSheet(); /*设置单元格列宽*/ $sheet->getColumnDimension('A')->setWidth(20); $sheet->getColumnDimension('B')->setWidth(15); $sheet->getColumnDimension('C')->setAutoSize(true); /*设置字体大小*/ $sheet->getStyle('A1:c1')->getFont()->setBold(true)->setName(

How to retrieve date from table cell using PhpSpreadsheet?

只谈情不闲聊 提交于 2019-12-07 01:47:02
问题 I have xlsx tables and I use PhpSpreadsheet to parse them. Some cells format is date. The problem is that PhpSpreadsheet returns the values from date-formatted cells in an unspecified format: // How it looks in excel: 2017.04.08 0:00 $value = $worksheet->getCell('A1')->getValue(); // 42833 - doesn't look like a UNIX time How to get the date from a cell in form of a UNIX time or a DateTimeInterface instance? 回答1: The value is amount of days passed since 1900. You can use the PhpSpreadsheet

yii2框架中整合PHPOffice的PhpSpreadsheet开源库

纵饮孤独 提交于 2019-12-06 16:48:20
在所有的php office库( http://www.21doc.net/php/awesomephp#Office ),以前用得最多的版本是PHPOffice/PHPExcel( https://github.com/PHPOffice/PHPExcel ),不过该库最后更新的版本为2015发布的1.8.1版本,已经终止维护,官方也不建议用户继续使用。 官方不维护PHPExcel后,新起一个项目叫PhpSpreadsheet( https://github.com/PHPOffice/PhpSpreadsheet )。新项目使用了大量的php新特性,比如命名空间,PSR标准,性能也比PHPExcel高了不少。 在使用时,由于PhpSpreadsheet是在原PHPExcel基础上开发的,PhpSpreadsheet接口api操作上也和旧的PHPExcel相似,而且支持更多的格式。 整合到yii2框架 下载phpspreadsheet,当前最新版本1.5.0 方式一,composer下载 composer require phpoffice/phpspreadsheet 方式二,对于部分不能用composer顺利下载的用户,可以手工下载源码 PhpSpreadsheet 下载地址: https://github.com/PHPOffice/PhpSpreadsheet

Read Xlsx file in PhpSpreadsheet

故事扮演 提交于 2019-12-06 06:35:11
问题 I want to read an xlsx file that was created in Microsoft Excel, but when I run the following code... $Source_File = "test.xlsx"; $Spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($Source_File); ...I receive the following error: Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Reader\Exception: Unable to identify a reader for this file in /var/www/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php:163 Stack trace: #0 /var/www/html/vendor/phpoffice/phpspreadsheet/src