PHP XLS.class创建READ-ONLY文件。救命!

时间:2011-04-19 04:05:28

标签: php excel permissions file-permissions xls

我正在使用XLS类从这里下载的数据库中用PHP创建电子表格文件: http://www.phpclasses.org/package/6583-PHP-Compose-and-generate-Excel-XLS-spreadsheet-files.html

正在生成的XLS文件似乎只是READ。我无法编辑该文件。

我需要能够编辑这些文件。甚至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);

1 个答案:

答案 0 :(得分:2)

它看起来像是一个受保护的文件,因为它来自互联网。我已经更改了受保护的文件设置,一切似乎都有效。