Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uncaught exception BadMethodCallException #472

Closed
clarkk opened this issue Jan 23, 2015 · 4 comments
Closed

uncaught exception BadMethodCallException #472

clarkk opened this issue Jan 23, 2015 · 4 comments

Comments

@clarkk
Copy link

clarkk commented Jan 23, 2015

docx file

http://www.filedropper.com/141228magmafaktura334andershermansen

require_once \Ini::get('path/class').'/third-party/phpword/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();

\PhpOffice\PhpWord\Settings::setPdfRendererPath(\Ini::get('path/class').'/third-party/tcpdf');
\PhpOffice\PhpWord\Settings::setPdfRendererName('TCPDF');

$word = \PhpOffice\PhpWord\IOFactory::load($file_dst);
$writer = \PhpOffice\PhpWord\IOFactory::createWriter($word, 'PDF');
$writer->save($tmp_file);

error

PHP Fatal error: Uncaught exception 'BadMethodCallException' with message 'Cannot add PreserveText in Cell.' in /var/www/dyntest.dk/class/third-party/phpword/Element/AbstractContainer.php:276
Stack trace:
#0 /var/www/dyntest.dk/class/third-party/phpword/Element/AbstractContainer.php(119): PhpOffice\PhpWord\Element\AbstractContainer->checkValidity('PreserveText')
#1 [internal function]: PhpOffice\PhpWord\Element\AbstractContainer->addElement('PreserveText', '{ =SUM(ABOVE) }', NULL, Array)
#2 /var/www/dyntest.dk/class/third-party/phpword/Element/AbstractContainer.php(101): call_user_func_array(Array, Array)
#3 /var/www/dyntest.dk/class/third-party/phpword/Reader/Word2007/AbstractPart.php(137): PhpOffice\PhpWord\Element\AbstractContainer->__call('addPreserveText', Array)
#4 /var/www/dyntest.dk/class/third-party/phpword/Reader/Word2007/AbstractPart.php(137): PhpOffice\PhpWord\Element\Cell->addPreserveText('{ =SUM(ABOVE) }', NULL, Array)
#5 /var/www/dyntest.dk/class/third-party/phpword/Reader/Word2007/AbstractPart.php(294): PhpOff in /var/www/dyntest.dk/class/third-party/phpword/Element/AbstractContainer.php on line 276


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Depicus
Copy link

Depicus commented Jan 29, 2015

Same for me.

try {
    $phpWord = \PhpOffice\PhpWord\IOFactory::load('docs/newfile.docx');
    $properties = $phpWord->getDocInfo();
    echo date('H:i:s'), ' loaded doc...', EOL;
    $properties->setCreator('Sukh Large Forehead Sanghera');
    $properties->setCompany('Agency Manager');
} catch (\BadMethodCallException $e) {
    echo date('H:i:s'), ' error ...' . $e, EOL;
}

and error

15:25:21 error ...exception 'BadMethodCallException' with message 'Cannot add Title in Cell.' in /Library/WebServer/AMCloud/vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php:228 Stack trace: #0 /Library/WebServer/AMCloud/vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php(130): PhpOffice\PhpWord\Element\AbstractContainer->checkValidity('Title') #1 [internal function]: PhpOffice\PhpWord\Element\AbstractContainer->addElement('Title', '4 Bakersgate Co...', '1') #2 /Library/WebServer/AMCloud/vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php(112): call_user_func_array(Array, Array) #3 /Library/WebServer/AMCloud/vendor/phpoffice/phpword/src/PhpWord/Reader/Word2007/AbstractPart.php(159): PhpOffice\PhpWord\Element\AbstractContainer->__call('addTitle', Array) #4 /Library/WebServer/AMCloud/vendor/phpoffice/phpword/src/PhpWord/Reader/Word2007/AbstractPart.php(159): PhpOffice\PhpWord\Element\Cell->addTitle('4 Bakersgate Co...', '1') #5 /Library/WebServer/AMCloud/vendor/phpoffice/phpword/src/PhpWord/Reader/Word2007/AbstractPart.php(298): PhpOffice\PhpWord\Reader\Word2007\AbstractPart->readParagraph(Object(PhpOffice\PhpWord\Shared\XMLReader), Object(DOMElement), Object(PhpOffice\PhpWord\Element\Cell), 'document') #6 /Library/WebServer/AMCloud/vendor/phpoffice/phpword/src/PhpWord/Reader/Word2007/Document.php(58): PhpOffice\PhpWord\Reader\Word2007\AbstractPart->readTable(Object(PhpOffice\PhpWord\Shared\XMLReader), Object(DOMElement), Object(PhpOffice\PhpWord\Element\Section)) #7 /Library/WebServer/AMCloud/vendor/phpoffice/phpword/src/PhpWord/Reader/Word2007.php(94): PhpOffice\PhpWord\Reader\Word2007\Document->read(Object(PhpOffice\PhpWord\PhpWord)) #8 /Library/WebServer/AMCloud/vendor/phpoffice/phpword/src/PhpWord/Reader/Word2007.php(69): PhpOffice\PhpWord\Reader\Word2007->readPart(Object(PhpOffice\PhpWord\PhpWord), Array, 'Document', 'docs/newfile.do...', 'word/document.x...') #9 /Library/WebServer/AMCloud/vendor/phpoffice/phpword/src/PhpWord/IOFactory.php(78): PhpOffice\PhpWord\Reader\Word2007->load('docs/newfile.do...') #10 /Library/WebServer/AMCloud/cwd.php(148): PhpOffice\PhpWord\IOFactory::load('docs/newfile.do...') #11 {main}

@Nublust
Copy link

Nublust commented Oct 23, 2015

More here:

    dd(\PhpOffice\PhpWord\IOFactory::load(storage_path('app/generated_movements/document.docx')));

BadMethodCallException in AbstractContainer.php line 228:
Cannot add Title in Cell.
in AbstractContainer.php line 228
at AbstractContainer->checkValidity('Title') in AbstractContainer.php line 130
at AbstractContainer->addElement('Title', 'xxx', '4')
at call_user_func_array(array(object(Cell), 'addElement'), array('Title', 'xxx', '4')) in AbstractContainer.php line 112
at AbstractContainer->__call('addTitle', array('xxx', '4')) in AbstractPart.php line 159
at Cell->addTitle('xxx', '4') in AbstractPart.php line 159
at AbstractPart->readParagraph(object(XMLReader), object(DOMElement), object(Cell), 'document') in AbstractPart.php line 298
at AbstractPart->readTable(object(XMLReader), object(DOMElement), object(Section)) in Document.php line 58
at Document->read(object(PhpWord)) in Word2007.php line 94
at Word2007->readPart(object(PhpWord), array('main' => array('rId1' => array('type' => 'officeDocument', 'target' => 'word/document.xml', 'docPart' => 'word/document'), 'rId2' => array('type' => 'thumbnail', 'target' => 'docProps/thumbnail.jpeg', 'docPart' => 'docProps/thumbnail.jpeg'), 'rId3' => array('type' => 'core-properties', 'target' => 'docProps/core.xml', 'docPart' => 'docProps/core'), 'rId4' => array('type' => 'extended-properties', 'target' => 'docProps/app.xml', 'docPart' => 'docProps/app')), 'document' => array('rId1' => array('type' => 'numbering', 'target' => 'word/numbering.xml', 'docPart' => 'numbering'), 'rId2' => array('type' => 'styles', 'target' => 'word/styles.xml', 'docPart' => 'styles'), 'rId3' => array('type' => 'http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects', 'target' => 'word/stylesWithEffects.xml', 'docPart' => 'stylesWithEffects'), 'rId4' => array('type' => 'settings', 'target' => 'word/settings.xml', 'docPart' => 'settings'), 'rId5' => array('type' => 'webSettings', 'target' => 'word/webSettings.xml', 'docPart' => 'webSettings'), 'rId6' => array('type' => 'image', 'target' => 'word/media/image1.jpeg', 'docPart' => 'media/image1.jpeg'), 'rId7' => array('type' => 'fontTable', 'target' => 'word/fontTable.xml', 'docPart' => 'fontTable'), 'rId8' => array('type' => 'theme', 'target' => 'word/theme/theme1.xml', 'docPart' => 'theme/theme1'))), 'Document', '/home/vagrant/Code/andusia/storage/app/generated_movements/document.docx', 'word/document.xml') in Word2007.php line 69
at Word2007->load('/home/vagrant/Code/andusia/storage/app/generated_movements/document.docx') in IOFactory.php line 78
at IOFactory::load('/home/vagrant/Code/andusia/storage/app/generated_movements/document.docx') in routes.php line 18
at RouteServiceProvider->{closure}()
at call_user_func_array(object(Closure), array()) in Route.php line 155
at Route->runCallable(object(Request)) in Route.php line 130
at Route->run(object(Request)) in Router.php line 704
at Router->Illuminate\Routing{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 706
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54

Has there been any movement on this?

@akaramires
Copy link

Any news?

@troosan
Copy link
Contributor

troosan commented Dec 25, 2017

fixed in 0.14

@troosan troosan closed this as completed Dec 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants