I am trying to change the name of all sheets exported to xlsx from my code below. Export works fine, but the title of all worksheets is just worksheet 1, 2, 3, etc.
I want to grab the names from the "filename" column from my php database.
For example, worksheet1-> aaa
I want this to become: asset1-> aaa
Greetings
/** Query 1.0 */ $query = "SELECT * FROM asset_register"; $query2 = "SELECT asset_name FROM asset_register"; if ($result = mysql_query($query) or die(mysql_error())) { /** Create a new PHPExcel object 1.0 */ $objPHPExcel = new PHPExcel(); $objPHPExcel->getActiveSheet()->setTitle('Data'); } /** Loop through the result set */ $rowNumber = 1; //start in row 1 $objPHPExcel->removeSheetByIndex(0); while ($row = mysql_fetch_row($result)) { $newsheet = $objPHPExcel->createSheet(); $col = 'A'; // start at column A $objPHPExcel->getActiveSheet()->setTitle(mysql_query($query2)); foreach($row as $cell) { $newsheet->setCellValue($col.$rowNumber,$cell); $col++; }
Tuzki source share