PHPExcelを覚えている最中なのですが、
こちらのサイトを参考に試行錯誤しています。
最初のテンプレートファイルを読み込む段階でエラーがでてしまうのですが、何が原因なのでしょうか?
Classesフォルダも同じ階層にありますし、原因が分かりません。
//PHPExcelファイルの読み込み include_once ( __DIR__ . '/Classes/PHPExcel.php'); include_once ( __DIR__ . '/Classes/PHPExcel/IOFactory.php'); // Excel2007形式(xlsx)テンプレートの読み込み $reader = PHPExcel_IOFactory::createReader('Excel2007'); $excel = $reader->load( dirname(__FILE__) . '/book1.xls' );
Fatal error: Uncaught exception 'PHPExcel_Reader_Exception' with message 'Could not open C:\xampp\htdocs\testonly/book1.xls for reading! File does not exist.' in C:\xampp\htdocs\testonly\Classes\PHPExcel\Reader\Excel2007.php:347 Stack trace: #0 C:\xampp\htdocs\testonly\test.php(10): PHPExcel_Reader_Excel2007->load('C:\xampp\htdocs...') #1 {main} thrown in C:\xampp\htdocs\testonly\Classes\PHPExcel\Reader\Excel2007.php on line 347
ちなみにこれならエラーはでません。
テンプレートファイルを使いたいので上記のようにしたのですがしょっぱなからエラーがでるのです...
<?php if ( $_POST['mode'] === 'download' ) { //PHPExcelファイルの読み込み include_once ( __DIR__ . '/Classes/PHPExcel.php'); include_once ( __DIR__ . '/Classes/PHPExcel/IOFactory.php'); //エクセルファイルの新規作成 $excel = new PHPExcel(); // シートの設定 $excel->setActiveSheetIndex(0);//何番目のシートか $sheet = $excel->getActiveSheet();//有効になっているシートを代入 // セルに値を入力 $sheet->setCellValue('A8', 'こんにちは!');//A1のセルにこんにちは!という値を入力 // Excel2007形式で出力する $writer = PHPExcel_IOFactory::createWriter($excel, 'Excel2007'); $writer->save(dirname(__FILE__) . '/output.xls'); } ?> <html> <body> <form action="" method="post"> <input type="submit" value="csvダウンロード"><br /> <input type="hidden" name="mode" value="download"> </form> </body> </html>

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/07/05 14:33
退会済みユーザー
2016/07/05 14:34
退会済みユーザー
2016/07/05 14:35
2016/07/05 14:49
退会済みユーザー
2016/07/05 14:50
2016/07/05 14:51