php 导出复杂表头表头格式错乱
$Head = array(
array('value' => $year."年省直单位申购车辆申请呈批表",'col' => 19,'row' => 3,
'children' =>
array(
array('value' => $date,'col' => 4,'row' => 1,
'children' =>
array(
array('value' => '序号','col' => 1,'row' => 3),
array('value' => '单位','col' => 1,'row' => 3,'width' => 25),
array('value' => '机关有关情况','col' => 6,'row' => 1,
'children' =>
array(
array('value' => '规格','col' => 1,'row' => 2),
array('value' => '性质','col' => 1,'row' => 2),
array('value' => '经费供应渠道','col' => 1,'row' => 2,'width' => 25),
array('value' => '领导职数','col' => 1,'row' => 2,'width' => 25),
array('value' => '人员编制','col' => 1,'row' => 2,'width' => 25,),
array('value' => '离退休干部数','col' => 1,'row' => 2,'width' => 25)
)
),
array('value' => '现有车辆情况','col' => 3,'row' => 1,
'children' =>
array(
array('value' => '编制车数','col' => 1,'row' => 2,'width' => 25),
array('value' => '实有车数','col' => 1,'row' => 2,'width' => 25),
array('value' => '应报废车辆数','col' => 1,'row' => 2,'width' => 25)
)
),
array('value' => '申购车辆情况','col' => 7,'row' => 1,
'children' =>
array(
array('value' => '厂牌型号','col' => 1,'row' => 2,'width' => 25),
array('value' => '种类','col' => 1,'row' => 2),
array('value' => '排量或座位数','col' => 1,'row' => 2,'width' => 25),
array('value' => '数量','col' => 1,'row' => 2),
array('value' => '单价','col' => 1,'row' => 2),
array('value' => '经费合计','col' => 1,'row' => 2,'width' => 25),
array('value' => '经费来源','col' => 1,'row' => 2,'width' => 25)
)
),
array('value' => '备注','col' => 1,'row' => 3)
)
),
array('value' => '','col' => 13),
array('value' => '金额单位:万元','col' => 2),
)
)
);
$arr = array();
$data = array();
while ($row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC)) {
$data['rownum'] = $row['rownum'];
$data['companyname'] = $row['companyname'];
$data['unitspec'] = $row['unitspec'];
$data['unitprop'] = $row['unitprop'];
$data['fundspychannels'] = $row['fundspychannels'];
$data['officepostnum'] = $row['officepostnum'];
$data['staffnum'] = $row['staffnum'];
$data['retirednum'] = $row['retirednum'];
$data['quotacar'] = $row['quotacar'];
$data['availcar'] = $row['availcar'];
$data['scrapcar'] = $row['scrapcar'];
$data['brand'] = $row['brand'];
$data['cartype'] = $row['cartype'];
$data['output'] = $row['output'];
$data['num'] = $row['num'];
$data['oneprice'] = $row['oneprice'];
$data['price'] = $row["num"]*$row["oneprice"];
$data['afundfrom'] = $row['afundfrom'];
$data['remark'] = $row['remark'];
array_push($arr,$data);
}
$phpExcelCore = new PHPExcelCore();
$fn = $phpExcelCore::RecursionCreateExecl($Head,$arr);
好奇怪此处出现了几个空格,貌似是$head格式有点问题。
此处一行空白如何去掉?
最后一行加一个合计又如何加上去呢?
这两行怎么放到head头里面?
空格处理:合并单元格的代码需要改一下,网上的东西好多地方有坑的。。
整体的格式需要处理一下head:
$year = date('Y');
对于合计需要在data后面追加一行:
如果哪位大神能把第二行的两条竖线能去掉就更加完美了