I have a problem with some column of my excel file that I export from php. Others column is working fine with the formula but another two columns have problem
I think this not problem with the formula, because the formula just working fine when I hit enter on the cell to execute manually.
Anyone know how to solved this?
Thanks in advanced.
Here is screen shoot of the column
Here is my code of header
header("Content-Type: application/vnd.ms-excel;");
date_default_timezone_set("Asia/Jakarta");
header("Content-Disposition: attachment; filename=Laporan_Absensi_".date("d-m-Y").date("_H-i"));
For the problem of point 1., here is the code how I set the column
<td style="vnd.ms-excel.numberformat:#,##0_) \Rp;" align="right"><?=$penalty?></td>
For the problem of point 2., here is the code how I set the column
<td style="background-color:#99CCFF;vnd.ms-excel.numberformat:h:mm;" align="right"><?=$form?></td>
$penalty
and $form
is the variable where I store the formula
It would be something like this:
$result = mysql_query('SELECT * FROM `some_table`');
if (!$result) die('Couldn\'t fetch records');
$num_fields = mysql_num_fields($result);
$headers = array();
for ($i = 0; $i < $num_fields; $i++)
{
$headers[] = mysql_field_name($result , $i);
}
$fp = fopen('php://output', 'w');
if ($fp && $result)
{
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="export.csv"');
header('Pragma: no-cache');
header('Expires: 0');
fputcsv($fp, $headers);
while ($row = mysql_fetch_row($result))
{
fputcsv($fp, array_values($row));
}
die;
}