0
后,这是我的代码从哪里作者,创建日期,标题在Excel中来使用PHPExcel
<?php
if($_POST['submited'])
{
if($_POST['dwnld_query']=="All applicants")
{
$q="select * from es_enquiry";
$result=mysql_query($q);
}
header("Content-Type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename='".$_POST['dwnld_query']."'.xls");
// print your data here. note the following:
// - cells/columns are separated by tabs ("\t")
// - rows are separated by newlines ("\n")
echo 'RegNo'."\t".'App for class'."\t".'FirstName'."\t".'Middle-Name'."\t".'Last-Name'."\t".'Gender'."\t".'Father Name'."\t".'DOB'."\t".'AGE'."\t".'Child Category'."\t".'Parent Category'."\t".'TC Case'."\t".'Last School Name'."\t".'TC Date'."\t". 'TC No'."\t".'CGPA'."\n";
$tc_case;
$tc_date;
$tc_no;
while($row=mysql_fetch_object($result))
{
if($row->last_school_type=="KV"){$tc_case="Yes";}
else{$tc_case="No";}
if($row->kv_tc_date==" ")
{
$tc_date="-";
}
else
{
$tc_date=$row->kv_tc_date;
}
if($row->kv_tc_no==" ")
{
$tc_no="-";
}
else
{
$tc_no=$row->kv_tc_date;
}
// for example:
echo $row->eq_application_no."\t".$row->eq_class."\t".$row->eq_name."\t".$row->mid_name."\t".$row->last_name."\t".$row->eq_sex."\t".$row->father_name."\t".$row->eq_dob."\t".$row->age."\t".$row->scat_id."\t".$row->parent_cate_id."\t".$tc_case ."\t".$row->eq_prv_acdmic."\t".$tc_date."\t".$tc_no."\t".$row->last_class_cgpa."\n";
}
}
?>
当我下载Excel文件,它显示出作者:马腾Balliauw,主题:Office 2007的XLSX测试文档,标题:Office 2007 XLSX测试文档,类别:测试结果文件,标签:office 2007 openxml php。就像你们在我的代码中看到的一样,没有提到这些,然后从这些来自哪里以及如何更改或删除它们。
OK我收到你的观点,但你看这个代码中不是一个单一属性上的Excel文档设置。 'require_once'Classes/PHPExcel.php'; require_once'Classes/PHPExcel/IOFactory.php'; $ objPHPExcel = new PHPExcel(); $ objPHPExcel-> setActiveSheetIndex(0); ('Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); 您的代码。 header('Content-Disposition:attachment; filename =“Enquiry_Format。'。xlsx”'); header('Cache-Control:max-age = 0'); $ objWriter = PHPExcel_IOFactory :: createWriter($ objPHPExcel,'Excel2007'); $ objWriter-> save('php:// output');' – user3100533
我在我的第二条评论中提到的代码中使用了您的代码,但属性并未出现在Excel文档中,您对此有何看法。 – user3100533
我的意见是,如果在Excel工作簿中看不到这些属性,则表示您已经做了错误的事情......正在生成的.xlsx文件显示的属性,因为某些属性有默认值如果你没有手动设置它们?如果您在/ Examples中运行脚本,他们是否正确显示属性? –