Please help me on the PHPEXCEL. it shows only one letter. this is my php code:
$sql_question = "SELECT * FROM tna_question WHERE title_id = '$tid' ORDER BY section_id";
$result_question = mysql_query($sql_question, $db);
$category = array();
while ($row = mysql_fetch_assoc($result_question)) {
$arr1 = $row['question'];
$arr = array_push($category ,$arr1);
$category_count++;
}
$arr3[] = $category;
the result from the sql query is an array:
Array ( [0] => gfhgfh [1] => gfhfg [2] => fggfdg [3] => fds [4] => asd [5] => fghgfh [6] => Policy Wordings / Coverage [7] => Risk Assessment / Survey & Underwriting [8] => Policy Wordings / Coverage [9] => Risk Assessment / Survey & Underwriting )
when i use this line:
$objPHPExcel->setActiveSheetIndex()->fromArray($category, NULL, 'C7');
it gives me only the first letter from each row
but if i make this one:
$objPHPExcel->setActiveSheetIndex()->fromArray($arr3, NULL, 'C7');
it'll give all the data in one row.
but The output that i want is like this:
You can use the below code to get the desired result :
foreach($arr3 as $k => $v){
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $k, $v);
}
Note : Changing the column value will make it go left and right only. In case you want to shift the entire thing down then replace $k by $k+$val where $val is the number of rows you want to shift down.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.