###実現したいこと
PHPExcelでファイルを作成しダウンロードさせるシステムを作っています。
そこでダウンロードしたファイルを開いたときに複数セルが選択されている状態にしたいです。
以下がエクセルを作成しているコードになります
PHP
1function createExcel() { 2 // 出力タイムアウトを3分に変更 3 set_time_limit(180); 4 5 ini_set('memory_limit' , '256M'); 6 7 // テンプレートのコピー 8 $template = "テンプレートファイルのパス"; 9 $savefile = "保存ファイル名"; 10 $dest = "保存場所".$savefile; 11 12 copy($template, $dest); 13 14 // PHPExcelオブジェクトの生成 15 $reader = PHPExcel_IOFactory::createReader('Excel2007'); 16 $xl = $reader->load($template); 17 18 $xl->setActiveSheetIndex(0); 19 $base_sheet = $xl->getActiveSheet(); 20 $temp_sheet[0] = $base_sheet->copy(); 21 $temp_sheet[0]->setTitle("newsheet0"); 22 23 $temp_sheet[1] = $base_sheet->copy(); 24 $temp_sheet[1]->setTitle("newsheet1"); 25 26 $temp_sheet[2] = $base_sheet->copy(); 27 $temp_sheet[2]->setTitle("newsheet2"); 28 29 $temp_sheet[3] = $base_sheet->copy(); 30 $temp_sheet[3]->setTitle("newsheet3"); 31 32 // ------------------------------- // 33 // データの書き込み(省略) // 34 // ------------------------------- // 35 36 // --- シートの追加 37 for ($i = 0; $i < count($temp_sheet_month); $i++) { 38 $xl->addSheet($temp_sheet[$i]); 39 } 40 41 $sheet = $xl->setActiveSheetIndex(2); 42 // --- セルを選択状態にする 43 $sheet->setSelectedCells("C6:AM209"); 44 45 // --- 不要なシートが2枚あるから削除 46 $xl->removeSheetByIndex(1); 47 $xl->removeSheetByIndex(0); 48 49 // Excel2007形式で保存 50 $writer = PHPExcel_IOFactory::createWriter($xl, 'Excel2007'); 51 $writer->save($dest); 52 53 // メモリ解放 54 $xl->disconnectWorksheets(); 55 unset($xl); 56 57 return $savefile; 58}

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/05 05:12