PHPOffice is an open-source collection of libraries used for reading and writing files in formats compatible with various "office" suites, such as Microsoft Office and OpenOffice.
Questions tagged [phpoffice]
242 questions
4
votes
3 answers
Problem in exporting data array to xlsx file using PhpSpreadsheet
Hello everyone in my project, I am trying to export data from database to an xlsx file but I am not getting correct data.I have attached image of data.
I am using the following code.
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use…

Yogendra
- 1,208
- 5
- 18
- 38
4
votes
1 answer
Cell entry A1 no longer exists in cache
I use PhpOffice\PhpSpreadsheet with Apcu caching, and i have this error
Error: Cell entry A1 no longer exists in cache. This probably means that the cache was cleared by someone else.
$pool = new \Cache\Adapter\Apcu\ApcuCachePool();
$simpleCache =…

Ekhrikhor
- 91
- 2
- 5
4
votes
2 answers
Creating a CSV File from a string using PhpSpreadsheet
Is this possible? or must one use a PHP library such as thephpleague/csv?
Example, according to PhpSpreadsheet's documentation:
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
$spreadsheet = $reader->load($file);
$writer = new…

tfont
- 10,891
- 7
- 56
- 52
4
votes
3 answers
Insert table inside phpWord template document
I have template.docx template with mark ${table} inside. I need to create table using phpWord and insert it in my template.docx instead ${table} mark inside. Here is my code example
//Create simple table
$document_with_table = new…

Teretto
- 635
- 2
- 10
- 22
4
votes
1 answer
How fix border in TcPDF writer in PhpSpreadsheet?
I've a PhpSpreadsheet process to export data to XLSX and PDF. I'm using TcPDF as PDF writer. But TcPDF has a problem to convert/translate border style.
Xlsx export
TcPDF export
Any idea to fix this?

Silas Ribas Martins
- 302
- 3
- 9
4
votes
0 answers
PHPWord Full-width table with landscape orientation
In my PHPWord document I have a section with landscape orientation and table in it. I want the table to be full-width, but if I add table like this (since width is in percent according to the docs):
$table = $section->addTable(array('width' =>…

Sergey Novikov
- 4,096
- 7
- 33
- 59
4
votes
3 answers
XML Parsing error; PHPWord
I am using PHPOffice/PHPWord in my Laravel Application. It is used to generate a .docx document with results in tables. This works great for a document of 3 tables with 6 rows, but when there are more rows the document is generated but when opening…

Anna Jeanine
- 3,975
- 10
- 40
- 74
3
votes
0 answers
PhpSpreadsheet Fatal Error "Could not find zip member"
Hi am using PhpSpreadsheet, and here is my code:
switch ($file_extension) {
case 'xlsx':
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
break;
case 'xls':
$reader = new…

VIKESIR
- 225
- 2
- 9
3
votes
1 answer
PhpPresentation Axis Label Format
I am trying to format the labels on the y axis
$axis->setFormatCode('#.0\%');
This is providing no change but I have confirmed that the format code is setting properly by adding an echo of getFormatCode(); in the writer class.
I have tested and this…

Kevin Smeeks
- 185
- 10
3
votes
1 answer
phpoffice line breaks removed when saving doc to pdf
I am having issue with phpoffice latest version not keeping line breaks I added to textrun when the generated template doc is saved as pdf. Below is the code that I using.
require_once 'bootstrap.php';
use PhpOffice\PhpWord\Settings;
use…

deepsingh
- 149
- 10
3
votes
1 answer
We found a problem with some content in 'Spreadsheet.xlsx'. Do you want us to try to recover as much as we can?
I have the following basic PHP project (just one file plus composer config):
composer.json
{
"config": {
"optimize-autoloader": true,
"platform": {
"php": "7.4.9"
}
},
"require": {
…

Viewsonic
- 827
- 2
- 15
- 34
3
votes
0 answers
Preview Word File instead of downloading in the browser using PHPWord in laravel
I want to preview created new Word file in a browser using PHPWord in Laravel
I have successfully managed to make a word file but now I want to preview it instead of downloading.
I have a system in it I am proving a file when it created.
PDF and…

always-a-learner
- 3,671
- 10
- 41
- 81
3
votes
1 answer
PhpWord TemplateProcessor clone table rows and insert information in them
I have a issue with the phpword tables.
I have the following table and I want to clone the first table row and replace the information in it. So far I have no progress. I've used getVariables() method to get all the variables from the document and…

Kristian Vasilev
- 504
- 8
- 26
3
votes
1 answer
'unoconv' script works in terminal but not when called through an exec() function in my laravel controller
I'm trying to use the following shell script to convert a docx file into a pdf:
unoconv -f pdf tempfile.docx
In Laravel, I have a controller function which I create a temp docx file using phpWord that I need to convert into a pdf and return the…

movac
- 1,576
- 3
- 21
- 45
3
votes
0 answers
Using PHP excel lib or python excel lib in PHP 7?
I have been working with both PHPExcel and Spreadsheet for generating and reading excel files in PHP5 but recently I've switched to PHP 7 that makes many trouble as those excel libs deprecated. I've searched a lot and finally I've found PHPOffice.…

Fatemeh Rostami
- 1,047
- 1
- 15
- 27