我使用一个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);
看起来它是作为一个受保护的文件打开的,因为它起源于互联网。我已经更改了我的保护文件设置,一切似乎都工作。