PHP XLS.class 创建只读文件。帮助!

发布于 2024-11-02 01:55:52 字数 1661 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

习惯成性 2024-11-09 01:55:52

它看起来像是作为受保护的文件打开的,因为它源自互联网。我已经更改了受保护的文件设置,一切似乎都正常。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文