简体   繁体   English

数据导出到excel并直接保存到目录(文件夹)

[英]Data export to excel & save directly to the directory (folder)

Currently on clicking on export user is prompt a box to save/open the export excel file to their system , though what i want is when user click on export/send data , the data get exported & save to the server on specific folder & later which I mail that file to the user as an attachment. 目前在单击导出用户时,会prompt a box用于将导出excel文件保存/打开到他们的系统,尽管我想要的是当用户单击导出/发送数据时,数据被exported & savespecific folder的服务器上,然后再保存我将该文件作为附件邮寄给用户。

Did I have to make any change in my header for the same ? 我是否必须对标题进行相同的任何更改?

For ref below is the header from my export excel library: 下面的参考是我的导出excel库的标头:

  header("Content-type: application/vnd.ms-excel"); 
  header("Content-Disposition: attachment; filename=$this->filename"); 
  header("Pragma: no-cache"); 
  header("Expires: 0"); 
  print "$header\n$data"; 

Thanks in advance. 提前致谢。

The only thing you really need to do is save the Excel contents to disk on your server, you can also remove those headers completely as they are only needed when outputting the data to the browser. 您唯一需要做的就是将Excel内容保存到服务器的磁盘上,您也可以完全删除这些标头,因为仅在将数据输出到浏览器时才需要这些标头。

When you mail the user, simply attach the file and send. 给用户发送邮件时,只需附加文件并发送即可。

It should be pretty straight forward. 它应该很简单。

EDIT: 编辑:

To save the excel file: 要保存excel文件:

file_put_contents('<your file name>', '<your file contents>');

The content can be any string, so if you have the excel file contents in a variable, simple put it there. 内容可以是任何字符串,因此,如果您将excel文件的内容包含在变量中,则只需将其放在此处即可。

The file name can be a relative or absolute path. 文件名可以是相对路径或绝对路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM