Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么获取文件时出错:“quot;“数据可能已丢失”;使用microsoft excel 2007版本以xls格式打开excel文件时?_Php_Excel - Fatal编程技术网

Php 为什么获取文件时出错:“quot;“数据可能已丢失”;使用microsoft excel 2007版本以xls格式打开excel文件时?

Php 为什么获取文件时出错:“quot;“数据可能已丢失”;使用microsoft excel 2007版本以xls格式打开excel文件时?,php,excel,Php,Excel,我正在生成excel文件。该文件已成功生成,但当我尝试打开它时,它显示错误。请建议我如何解决该问题 这是我的密码 require_once "../php_writeexcel-0.3.0/class.writeexcel_workbook.inc.php"; require_once "../php_writeexcel-0.3.0/class.writeexcel_worksheet.inc.php"; $fname = tempnam("/tmp", "demo.xls"); $wo

我正在生成excel文件。该文件已成功生成,但当我尝试打开它时,它显示错误。请建议我如何解决该问题

这是我的密码

 require_once "../php_writeexcel-0.3.0/class.writeexcel_workbook.inc.php";
 require_once "../php_writeexcel-0.3.0/class.writeexcel_worksheet.inc.php";

$fname = tempnam("/tmp", "demo.xls");
$workbook =& new writeexcel_workbook($fname);
$worksheet =& $workbook->addworksheet('Demo');
$worksheet2 =& $workbook->addworksheet('Another sheet');
$worksheet3 =& $workbook->addworksheet('And another');



$worksheet->set_column('A:C', 32);
$heading  =& $workbook->addformat(array(
                                        bold    => 1,
                                        color   => 'blue',
                                        size    => 18,
                                        merge   => 1,
                                        ));

$headings = array('Out Telco Wise Report', '');
$worksheet->write_row('C1', $headings, $heading);




$worksheet->write('A2', "Request From");
$worksheet->write('B2', "Out Telco");
$worksheet->write('C2', "Total");


$i=3;
while($rowres=mysql_fetch_array($result_excel))
{

            $sql3="select ceil(length(msg_body)/160) as no_sms, count(*)as total from outbox   ".$with_out_client." AND request_from='".$rowres['request_from']."' AND out_telco='".                 $rowres['out_telco']."'  group by no_sms";
                 $result2=mysql_query($sql3);
                 $count2=0;
                 while($row2 = mysql_fetch_array($result2))
                   {
                     $count2 =$count2+($row2['total']*$row2['no_sms']);             
                   }




$worksheet->write('A'.$i, $rowres["request_from"]);
$worksheet->write('B'.$i, $rowres["out_telco"]);
$worksheet->write('C'.$i, $count2);
$i++;
}


$workbook->close();


header("Content-Type:application/vnd.ms-excel; name=\"example-demo.xls\"");
header("Content-Disposition: attachment; filename=\"example-demo.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);