phpspreadsheet

Open XLSX file that protected by a password with PHPSpreadsheet

戏子无情 提交于 2021-02-19 01:23:46
问题 I'm trying to open an Excel file (.xlsx) that is protected by a password with PHPSpreadsheet (documentation). I know the password but I don't find a way to open it. The load() method of \PhpOffice\PhpSpreadsheet\Reader\Xlsx doesn't give the possibility to insert a password and when I try to load the file it returns an error (of course). use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); $spreadsheet =

Open XLSX file that protected by a password with PHPSpreadsheet

白昼怎懂夜的黑 提交于 2021-02-19 01:23:20
问题 I'm trying to open an Excel file (.xlsx) that is protected by a password with PHPSpreadsheet (documentation). I know the password but I don't find a way to open it. The load() method of \PhpOffice\PhpSpreadsheet\Reader\Xlsx doesn't give the possibility to insert a password and when I try to load the file it returns an error (of course). use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); $spreadsheet =

Write data from array to sheet using phpspreadsheet library

不羁的心 提交于 2021-02-08 12:32:55
问题 How can I create excel sheet column headers from array using phpspreadsheet library? Below is the code I am trying but it's not working: // $header is an array containing column headers $header = array("Customer Number", "Customer Name", "Address", "City", "State", "Zip"); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->fromArray($header, NULL, 'A1'); // redirect output to client browser header('Content-Type: application/vnd.ms-excel'); header('Content

PHPSpreadsheet generates invalid file with charts

不羁岁月 提交于 2021-02-07 09:33:46
问题 I am migrating the existing/working app from PHPExcel ( phpoffice/phpexcel: 1.8.0 ) to PHPSpreadsheet and I have hit an issue when generating Excel file containing one or more charts . Without any addChart calls, the generated file is valid, but as soon as I add a chart, the resulting file becomes invalid. Excel does attempt to recover the data, which succeeds but without a chart. Excel recovery tool shows: Excel completed file level validation and repair. Some parts of this workbook may have

PHPSpreadsheet generates invalid file with charts

主宰稳场 提交于 2021-02-07 09:32:01
问题 I am migrating the existing/working app from PHPExcel ( phpoffice/phpexcel: 1.8.0 ) to PHPSpreadsheet and I have hit an issue when generating Excel file containing one or more charts . Without any addChart calls, the generated file is valid, but as soon as I add a chart, the resulting file becomes invalid. Excel does attempt to recover the data, which succeeds but without a chart. Excel recovery tool shows: Excel completed file level validation and repair. Some parts of this workbook may have

PHPSpreadsheet loses styles of existing Charts during excel file editing

二次信任 提交于 2021-01-29 17:41:49
问题 I use PHPSpreadsheet to edit existed Excel file and add there some images. But sometimes it losses the styles of existed charts in an excel. It resets a background color or a scale of the chart. Some charts are left without changes. Could someone say why PHPSpreadsheet resets styles/scale of existed charts and how to suppress that side-effect? <?php include 'vendor/autoload.php'; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; use PhpOffice

Add Pictures to comments in PhpSpreadsheet

梦想与她 提交于 2021-01-29 15:15:33
问题 I have a comment in PhpSpreadsheet and I want to add a backgroundpicture to it. The comment is created like this: $spreadsheet->getActiveSheet()->getComment($cell)->getText()->createTextRun('Test text'); But there is nothing in the documentation about how to add a backgroundpicture to it. 回答1: I was able to solve my issue with a (bad, but working) workaround. It seems that PHPSpreadsheet is not able (yet) to create a backgroundpicture to a comment, maybe PHPSpreadsheet can do it in the future

how to set page orientation(landscape or portrait) in phpspreadsheet

血红的双手。 提交于 2021-01-28 13:40:47
问题 I want to set pagesetup in excel using phpspreadsheet. I found to do it using phpexcel from here. I do not know what to replace at PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT. $sheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); Thanks in advance. 回答1: I found the answer. I tried it after go through PageSetup.php in PHPSpreadsheet. $sheet->getPageSetup()->setOrientation(PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT); 来源: https

PhpSpreadsheet(暂记)

左心房为你撑大大i 提交于 2021-01-12 01:49:18
PHPExcel与PhpSpreadsheet? PhpSpreadsheet是PHPExcel的下一个版本。它打破了兼容性,大大提高了代码库质量(命名空间,PSR合规性,最新PHP语言功能的使用等)。 官网 : https://phpspreadsheet.readthedocs.io/en/develop/ 软件要求 使用PhpSpreadsheet开发需要以下软件: PHP 5.6或更高版本 PHP扩展php_zip已启用 PHP扩展php_xml已启用 启用PHP扩展php_gd2(如果没有编译) 新功能探索中…… 来源: oschina 链接: https://my.oschina.net/u/3268486/blog/1936440

Phpspreadsheet how to set autoheight for merged cell?

只谈情不闲聊 提交于 2020-12-06 16:01:54
问题 setWrapText work well for one cell, but not works for merged cell. Here is the code I use to set autosize for merged cell, but it not works. $sheet = $spreadsheet->getActiveSheet(); $sheet->fromArray([["1\n1\n2\n\n3\n"],range(1,3),['188196','test']]); $sheet->mergeCells('A1:D1'); $sheet->getStyle("A1:D1")->getAlignment()->setWrapText(true); unmerged cell: merged cell: 回答1: Maybe you must set a rowhight by calculation. See this article. You could try $spreadsheet->getActiveSheet()-