前提・実現したいこと
お世話になっております。
PHPExcel で Excelファイルを作成しています。
処理を実行した際に XMLWriter not found のエラーが解決できません。
こちらの解決方法がご存知でしたらご教示ください。
補足情報(FW/ツールのバージョンなど)
OS: macOS High Sierra 10.13.6
PHP: 5.3
環境・条件
環境
OS: macOS High Sierra 10.13.6
PHP: 5.3
条件
PHPのバージョンを上げてPhpSpreadsheetにするのは、プロジェクトの環境でできません。
発生している問題・エラーメッセージ
PHP Fatal error: Class 'XMLWriter' not found in プロジェクトのpath/vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/XMLWriter.php on line 37
該当のソースコード(実行プログラム)
php
1require_once '../vendor/phpoffice/phpexcel/Classes/PHPExcel.php'; 2require_once '../vendor/phpoffice/phpexcel/Classes/PHPExcel/IOFactory.php'; 3 4// Excelを作成する 5$objExcel = new PHPExcel(); 6 7// シートの設定 8$objExcel->setActiveSheetIndex(0); 9$objSheet = $objExcel->getActiveSheet(); 10 11// A1セルに「テスト」という文字列を設定 12$objSheet->setCellValue('A1', 'テスト'); 13 14// Excelのダウンロード 15$objWriter = PHPExcel_IOFactory::createWriter($objExcel, 'Excel2007'); 16header("Pragma: public"); 17header("Expires: 0"); 18header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 19header("Content-Type: application/force-download"); 20header("Content-Type: application/octet-stream"); 21header("Content-Type: application/download"); 22header("Content-Disposition: attachment;filename=" . "TestDownload.xlsx"); 23header("Content-Transfer-Encoding: binary "); 24$objWriter->save('php://output'); // ← ここの処理でエラーが発生するプログラムが呼ばれます
該当のソースコード(エラーのプログラム)
php
1class PHPExcel_Shared_XMLWriter extends XMLWriter // ← ここが36行目 2{ // ← ここが37行目 3 省略 4}
試したこと
試したこと①
以下の記事を参考に、
yum install php-xml
をやってみましたが、
Mac環境ということもあり、 command not found: yum のエラーが出ます。
2013.09.12 PHPExcelを使ってエクセルを出力
https://deep-blog.jp/engineer/phpexcel/
2014.10.10 PHPExcelのXMLWriter.phpエラー
https://okesys.net/2014/10/10/phpexcel%E3%81%AExmlwriter-php%E3%82%A8%E3%83%A9%E3%83%BC/
試したこと②
Mac環境なので、 homebrew で試してみましたが、 php-xml はパッケージにないようです。
brew install php-xml
エラーメッセージ
Error: No available formula with the name "php-xml" ==> Searching for a previously deleted formula (in the last month)... Error: No previously deleted formula found. ==> Searching for similarly named formulae... Error: No similarly named formulae found. ==> Searching taps... ==> Searching taps on GitHub... Error: No formulae found in taps.
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/12/03 10:06
2019/12/03 11:34
2019/12/03 11:37