Reputation: 73
while ($input = $data_query->fetch(PDO::FETCH_ASSOC))
{
$row++;
$letter2 = "A";
$row++;
$letter2 = "A";
$objPHPExcel->getActiveSheet()->SetCellValue($letter2++.$row, $input['emp_loan_code']);
$objPHPExcel->getActiveSheet()->SetCellValue($letter2++.$row, $input['date_from']);
$objPHPExcel->getActiveSheet()->SetCellValue($letter2++.$row, $input['date_to']);
if ($input['status'] == 0) {
$input['status'] = 'Pending';
$objPHPExcel->getActiveSheet()->SetCellValue($letter2++.$row, $input['status']);
}
elseif ($input['status'] == 1) {
$input['status'] = 'Paid';
$objPHPExcel->getActiveSheet()->SetCellValue($letter2++.$row, $input['status']);
}
elseif ($input['status'] == 2) {
$input['status'] = 'Cancel';
$objPHPExcel->getActiveSheet()->SetCellValue($letter2++.$row, $input['status']);
}
else{
$input['status'] = 'Request';
$objPHPExcel->getActiveSheet()->SetCellValue($letter2++.$row, $input['status']);
}
$objPHPExcel->getActiveSheet()->SetCellValue($letter2.$row, $input['amount'])->getStyle()->getNumberFormat()->setFormatCode('0.00');
}
i want to set the entire E column to be 2 decimal places and i already set it to 2 decimal buy the output is still 00.00000
how can i display the output 00.00 thanks
Upvotes: 1
Views: 972
Reputation: 201
Instead of using this:
$objPHPExcel->getActiveSheet()->SetCellValue($letter2.$row, $input['amount'])->getStyle()->getNumberFormat()->setFormatCode('0.00');
Try this:
$objPHPExcel->getActiveSheet()->SetCellValue($letter2.$row, number_format($input['amount'],2,'.',''));
Upvotes: 1