お世話になっております。
現在、web上でPDFをダウンロードする処理を作成しています。
PDF出力ボタンを押下で以下の関数が実行されるようになっております。
「public/temp/sample.xlsx」にExcelのテンプレートを用意し、そのテンプレを読み込み編集し、
「public/excel/sample.xlsx」に編集したExcelを保存します。
そして編集したExcelをLibreofficeのコマンドでPDFに変換させたいです。
原因が分からなかったので質問させていただきました。
よろしくお願いいたします。
php
1 /** 2 * PDF出力 3 */ 4 public function pdf(Request $request){ 5 6 //Libreofficeのパス 7 $LIBRE_PATH = "storage/install/LibreOfficePortable/App/libreoffice/program/soffice.exe"; 8 $month = $request->input('pdf_month'); 9 $code = $request->input('code'); 10 $name = $request->input('name'); 11 $filepath = public_path().'/temp/sample.xlsx'; 12 $dt = date('Y/m/d'); 13 $money = $this->getdata_sum($code, $month); 14 15 //Excel読み込み 16 Excel::load($filepath,function($excel)use($money,$month,$name){ 17 $date = date('Y年m月d日'); 18 $obj_sheet = $excel->getSheet(0); 19 $obj_sheet->setCellValue("W2", $date); 20 $obj_sheet->setCellValue("A3", $name); 21 $obj_sheet->setCellValue("F14", $month); 22 $obj_sheet->setCellValue("F15", number_format($money,2).'円'); 23 }) 24 ->store('xlsx',public_path().'/excel'); 25 26 $path = base_path('public'); 27 28 $command = "$LIBRE_PATH --headless --convert-to pdf:writer_pdf_Export $path/excel/sample.xlsx"; 29 30 passthru($command); 31 32 }
apacheのログには以下のように記載されていました。
apache
1指定されたパスが見つかりません。
以下、$commandの内容です。
"storage/install/LibreOfficePortable/App/libreoffice/program/soffice.exe --headless --convert-to pdf:writer_pdf_Export C:\xampp\htdocs\test\public/excel/sample.xlsx"
回答1件
あなたの回答
tips
プレビュー