Category : phpword

I am working with PHPWord and am building my table from php using this instruction: $table = new Table(array(‘borderSize’ => 4, ‘borderColor’ => ‘black’, ‘width’ => 15200, ‘unit’ => TblWidth::TWIP)); I would like to display three dates per table so if I have more than three dates I should have more than one table. I ..

Read more

Im using Laravel 8 and want to use PHPWord This is my controller <?php namespace AppHttpControllers; use Exception; use IlluminateHttpRequest; use IlluminateSupportFacadesDB; use IlluminateSupportFacadesResponse; class CWord extends Controller{ public function CreateWord() { $desc1 = DB::table(‘dummy’)->where(‘id’,1)->first(); $path = "assets_file/"; $my_template = new PhpOfficePhpWordTemplateProcessor(public_path($path.’helloWorld.docx’)); $my_template->setValue(‘name’, $desc1->content); try{ $my_template->saveAs(public_path($path.’user_1.docx’)); }catch (Exception $e){ //handle exception } return response()->download(public_path($path.’user_1.docx’)); } ..

Read more

I’m reading data from an XLSX file with help from PHPSpreadsheet. After referring to the documentation, I was able to display all the file contents in the browser. My code for doing that looks like this: <?php require ‘vendor/autoload.php’; use PhpOfficePhpSpreadsheetSpreadsheet; use PhpOfficePhpSpreadsheetCellCell; use PhpOfficePhpSpreadsheetWriterXlsx; $inputFileName = ‘table1.xlsx’; $spreadsheet = PhpOfficePhpSpreadsheetIOFactory::load($inputFileName); $worksheet = $spreadsheet->getActiveSheet(); echo ..

Read more

I would like to convert a complex word doc into PDF but face the following issues. If anyone has any suggestions or alternatives to phpword. Existing word doc has multiple pages with different styles and formattings. I tried using phpword to replace variables with data, but unable to add html tags/code, E.g. <ul><li>code</li><ul>, this turns ..

Read more

As part of the implementation of an electronic signature function. I need to add the signature at a specific position in the Word document. The position however could vary from one document to another. The only potential solution to this seems to be having a signature placeholder which gets replaced with the signature.png once the ..

Read more

I need to convert the data in the MYSQL database to Word. Word file My code require ‘./modules/vendor/autoload.php’; require ‘core.php’; $templateProcessor = new PhpOfficePhpWordTemplateProcessor(__DIR__ . ‘/wordfile.docx’); $topshiriqnoma = $connection->table(‘topshiriqnoma’)->where(‘chiqinn’, $id)->orderBy(‘id’, ‘desc’)->paginate(50); $nomi = $connection->table(‘topshiriqnoma’)->where(‘chiqinn’, $id)->orderBy(‘id’, ‘desc’)->first(); unlink(UPLOAD_PATH . ‘/porucheniya/’ . $item->chiqnm." ".shaklqisqa($item->chiqsh, $item->chiqnm) . ‘.docx’); foreach ($topshiriqnoma as $item) { $summahamma = str_replace(" ", "", ..

Read more

I created a docx file with PHPword and it works perfectly. Now I have another php file where I need to read the docx file. <?php require_once ‘PHPWord/bootstrap.php’; $phpWord = PhpOfficePhpWordIOFactory::createReader(‘Word2007’)->load(‘helloWorld.docx’); foreach($phpWord->getSections() as $section) { foreach($section->getElements() as $element) { if(method_exists($element,’getText’)) { print_r($element->getText()); } } } This prints out an array like so: Array ( [0] ..

Read more

I’m using PHPWord to create reports that make use of a .docx template. This library allows me to clone a block and clone table rows. However the examples are separate from each other. I need to combine both approaches because my template table looks like this: ${block_group} +——–+—————————————————————-+ | Group: | ${group} | +——–+————+—————————————————+ | ..

Read more