如何知道Excel是否已从php下载

时间:2019-06-29 06:46:14

标签: php mysql excel

我可以从PHP下载excel,但是一旦下载,我需要更新数据库中的信息,例如用户名,日期,记录数等。

如果Chrome下载设置要求提供位置信息,则说明用户可以取消下载并仍然会更新记录,这是错误的。因此,我需要知道是否可以通过某种方式来了解用户是否已成功下载excel。

我的导出excel代码:

$sql = "Select * from wb_bill_generation where invoice_no>'$from_invoice' and invoice_no<='$to_invoice'";
$result_gre=mysqli_query($con,$sql);
$res_gre=mysqli_num_rows($result_gre);

$xls_filename = 'ColonyReport_'.date('Y-m-d').'.xls'; // Define Excel (.xls)
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$xls_filename");
header("Pragma: no-cache");
header("Expires: 0"); 

print 'Cutomer Name' . "\t";
print 'Invoice No' . "\t";
print 'Previous Reading' . "\t";
print 'Current Reading' . "\t";
print 'Consumption' . "\t";
print 'Rate' . "\t";
print 'Amount' ."\t";
print("\n");

while($data = mysqli_fetch_assoc($result_gre))
{                   
    print $data['customer_name'] . "\t";
    print $data['invoice_no'] . "\t";
    print $data['opening_reading'] . "\t";
    print $data['current_reading'] . "\t";
    print $data['total_consumption'] . "\t";
    print $data['rate'] . "\t";
    print $data['total']."\t";

    print("\t");
    print("\n");
}

我发现我可以强制文件的位置,我认为这可能不是正确的方法。 预先感谢

0 个答案:

没有答案