我有想要在 Excel 表单中显示的信息。我不想简单地打印数据库中的数据。我想控制格式,但无法正确显示信息。
我的代码是:
$rep_disp = new new_report($db_link);
$rep_disp->export_summary_report_to_csv();
$out = '';
$i = 1;
foreach($rep_disp->inc_inc_t_list as $inc_t)
{
$inc_current = '';
$inc_current = reset($rep_disp->inc_t_curr_list[$inc_t]);
$inc_t_amo = $rep_disp->inc_t_amo_tot[$inc_t][$inc_current];
$out.= ','.$rep_disp->disp_inc_t_name($inc_t).',"","","","","'.$inc_t_amo.'","'.$rep_disp->disp_curr_name($inc_current).'",';
foreach($rep_disp->inc_loc_list[$inc_t] as $inc_loc)
{
$k = 0;
$out.= '\n,"","","'.$rep_disp->disp_loc_name($inc_loc).'",';
foreach ($rep_disp->inc_cur_list[$inc_t][$inc_loc] as $inc_curr)
{
/*emptying the variable to ensure a new information on each line or no display if there's none*/
$inc_t_amo = '';
$inc_current = '';/*this is the current currency that we are working on. It's independent from the foreach loop we use for the currency*/
$inc_var_test = next($rep_disp->inc_t_curr_list[$inc_t]);/*will use to check if there's information to show*/
if($inc_var_test <> '' and isset($rep_disp->inc_t_amo_tot[$inc_t][$inc_var_test]))
{
$inc_t_amo = $rep_disp->inc_t_amo_tot[$inc_t][$inc_var_test];
$inc_current = $rep_disp->disp_curr_name($inc_var_test);
}
if($k == 0)
{
$out.='"'.$rep_disp->inc_loc_tot_list[$inc_t][$inc_loc][$inc_curr].'","'.$rep_disp->disp_curr_name($inc_curr).'","","'.$inc_t_amo.'","'.$inc_current.'",\n';
}
elseif($k > 0)
{
$out.= '\n,"","","","'.$rep_disp->inc_loc_tot_list[$inc_t][$inc_loc][$inc_curr].'","'.$rep_disp->disp_curr_name($inc_curr).'","","'.$inc_t_amo.'","'.$inc_current.'",\n';
}
$k++;
}
}
}