PHP XLS.class 创建只读文件。帮助!
我正在使用 XLS 类从从此处下载的数据库创建 PHP 电子表格文件: http://www.phpclasses .org/package/6583-PHP-Compose-and-generate-Excel-XLS-spreadsheet-files.html
正在生成的 XLS 文件似乎是只读的。我无法编辑该文件。
我需要能够编辑这些文件。甚至 CHMOD 似乎也不起作用。下面是我的代码。
请帮忙,我似乎无法弄清楚。谢谢!
ob_start();
// start the file
xlsBOF();
xlsWriteLabel(0,0,"Order Number");
xlsWriteLabel(0,1,"Month");
xlsWriteLabel(0,2,"Name");
xlsWriteLabel(0,3,"Address");
xlsWriteLabel(0,4,"Address 2");
xlsWriteLabel(0,5,"City");
xlsWriteLabel(0,6,"State");
xlsWriteLabel(0,7,"Zip");
xlsWriteLabel(0,8,"Country");
xlsWriteLabel(0,9,"Email");
$xlsRow = 1;
while(list($id,$fname,$lname,$email,$s_address,$s_address2,$s_city,$s_state,$s_zip,$s_country,$months_shipped)=mysql_fetch_row($result)) {
++$i;
xlsWriteNumber($xlsRow,0,$id);
xlsWriteNumber($xlsRow,1,$months_shipped+1);
xlsWriteLabel($xlsRow,2,"$fname $lname");
xlsWriteLabel($xlsRow,3,"$s_address");
xlsWriteLabel($xlsRow,4,"$s_address2");
xlsWriteLabel($xlsRow,5,"$s_city");
xlsWriteLabel($xlsRow,6,"$s_state");
xlsWriteLabel($xlsRow,7,"$s_zip");
xlsWriteLabel($xlsRow,8,"$s_country");
xlsWriteLabel($xlsRow,9,"$email");
$xlsRow++;
}
xlsEOF();
$filepath="/home/nick/Dropbox/Daily-Shipments/".date("m-d-y")."-Daily-Shipments.xls";
if (file_put_contents($filepath, ob_get_clean())) {
// Permissions for everything
chmod($filepath, 0777);
I am using an XLS class to create a spreadsheet file in PHP from a database downloaded from here:
http://www.phpclasses.org/package/6583-PHP-Compose-and-generate-Excel-XLS-spreadsheet-files.html
The XLS files that are being generated seem to be READ ONLY. I cannot edit the file.
I need to be able to edit these files. Not even a CHMOD seems to work. Below is my code.
Please help, I can't seem to figure it out. Thanks!
ob_start();
// start the file
xlsBOF();
xlsWriteLabel(0,0,"Order Number");
xlsWriteLabel(0,1,"Month");
xlsWriteLabel(0,2,"Name");
xlsWriteLabel(0,3,"Address");
xlsWriteLabel(0,4,"Address 2");
xlsWriteLabel(0,5,"City");
xlsWriteLabel(0,6,"State");
xlsWriteLabel(0,7,"Zip");
xlsWriteLabel(0,8,"Country");
xlsWriteLabel(0,9,"Email");
$xlsRow = 1;
while(list($id,$fname,$lname,$email,$s_address,$s_address2,$s_city,$s_state,$s_zip,$s_country,$months_shipped)=mysql_fetch_row($result)) {
++$i;
xlsWriteNumber($xlsRow,0,$id);
xlsWriteNumber($xlsRow,1,$months_shipped+1);
xlsWriteLabel($xlsRow,2,"$fname $lname");
xlsWriteLabel($xlsRow,3,"$s_address");
xlsWriteLabel($xlsRow,4,"$s_address2");
xlsWriteLabel($xlsRow,5,"$s_city");
xlsWriteLabel($xlsRow,6,"$s_state");
xlsWriteLabel($xlsRow,7,"$s_zip");
xlsWriteLabel($xlsRow,8,"$s_country");
xlsWriteLabel($xlsRow,9,"$email");
$xlsRow++;
}
xlsEOF();
$filepath="/home/nick/Dropbox/Daily-Shipments/".date("m-d-y")."-Daily-Shipments.xls";
if (file_put_contents($filepath, ob_get_clean())) {
// Permissions for everything
chmod($filepath, 0777);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它看起来像是作为受保护的文件打开的,因为它源自互联网。我已经更改了受保护的文件设置,一切似乎都正常。
It looks like it is being opened as a protected file as it originated from the internet. I have changed my protected file settings, and everything seems to work.