数据导出到excel&直接保存到目录(文件夹) [英] Data export to excel & save directly to the directory (folder)

查看:245
本文介绍了数据导出到excel&直接保存到目录(文件夹)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前单击导出用户是提示一个框保存/打开导出excel文件到他们的系统,虽然我想要的是当用户点击导出/发送数据,数据得到 export&将保存到特定文件夹&稍后我将该文件作为附件发送给用户。



我的标题是否必须进行相同的更改?



下面的引用是我的导出excel库的标题:

 标题(Content-type:应用/ vnd.ms-EXCEL); 
header(Content-Disposition:attachment; filename = $ this-> filename);
header(Pragma:no-cache);
header(Expires:0);
print$ header \ $ $ data;

提前感谢

解决方案

您真正需要做的只是将Excel内容保存到服务器上的磁盘上,也可以将输出数据的浏览器的数据完全删除。 >

当您邮寄用户时,只需附加文件并发送。



应该很直接。



编辑:



要保存excel文件:



file_put_contents('<你的文件名>','<你的文件内容>');



内容可以是任何字符串,所以如果你有一个变量中的excel文件内容,简单的放在那里。



文件名可以是相对路径或绝对路径。


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.

Did I have to make any change in my header for the same ?

For ref below is the header from my export excel library:

  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.

When you mail the user, simply attach the file and send.

It should be pretty straight forward.

EDIT:

To save the excel file:

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.

The file name can be a relative or absolute path.

这篇关于数据导出到excel&amp;直接保存到目录(文件夹)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆