I use PHPExcel to export my files from the database, but my problem is that when I load my excel, the name of my sheet is the default sheet. I would like to install it under another name, for example "Hello world".
Here is my code so far
require_once dirname(__FILE__) . '/Classes/PHPExcel.php'; $objPHPExcel = new PHPExcel(); $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', '1') ->setCellValue('B1', '2') ->setCellValue('C1', '3') ->setCellValue('D1', '4') ->setCellValue('E1', '5') ->setCellValue('F1', '6') ->setCellValue('G1', '7') ->setCellValue('H1', '8') ->setCellValue('I1', '9') ->setCellValue('J1', '10'); $row = 2; while($rowz = $result->fetch(PDO::FETCH_ASSOC)) { $col = 0; foreach($rowz as $key=>$value) { $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $value); $col++; } $row++; }
How can I set a new title for my worksheet? Thanks!
php excel phpexcel
user3796899
source share