与Pear-Spreadsheet_Excel_Writer只读文件

时间:2022-01-08 07:16:41

I'm generating Excel file with ..Pear-Spreadsheet_Excel_Writer-0.9.3

我正在用.Pear-Spreadsheet_Excel_Writer-0.9.3生成Excel文件

My file is generated without any errors but, it is in < Read-Only > Mode,

我的文件生成时没有任何错误,但它处于 <只读> 模式,

I researched but couldn't find the result except, permission on my local folders where excel output is stored, I tried all CHMOD things, but still the file is being generated in Read-Only Mode. I want to disable this Read-Only Mode.

我搜索了一下,但是没有找到结果,除了在本地文件夹中存储excel输出的权限,我尝试了所有的CHMOD功能,但是仍然是以只读模式生成文件。我想禁用这个只读模式。

sample Code is....

示例代码是....

    <?php

    require_once 'Spreadsheet/Excel/Writer.php';
    $workbook = new Spreadsheet_Excel_Writer('/tmp/yXcel.ods');

    //$workbook->setTempDir('/tmp/');
    $format_bold =& $workbook->addFormat();
    $format_bold->setBold();

    $format_title =& $workbook->addFormat();
    $format_wrap =& $workbook->addFormat();
    $format_title->setBold();
    $format_title->setColor('yellow');
    $format_title->setPattern(10);
    $format_title->setFgColor('blue');
    // let's merge
    $format_title->setAlign('merge');
    $format_wrap->setTextWrap(2);

    $format_top =& $workbook->addFormat();
    $format_top->setAlign('top');
    $format_top->setTextWrap(1);

    // center the text horizontally
    $format_center =& $workbook->addFormat();
    $format_center->setAlign('center');

    // put text at the top and center it horizontally
    $format_top_center =& $workbook->addFormat();
    $format_top_center->setAlign('top');
    $format_top_center->setAlign('center');



    $worksheet =& $workbook->addWorksheet();
    $worksheet->write(0, 0, "Title with Merged Cells", $format_title);
    // Couple of empty cells to make it look better
    $worksheet->write(0, 1, "", $format_title);
    $worksheet->write(0, 2, "", $format_title);
    $worksheet->write(0, 3, "", $format_title);
    $worksheet->write(1, 0, "Quarter", $format_bold);
    $worksheet->write(1, 1, "Profit", $format_bold);
    $worksheet->write(2, 0, "Q1asddddddddddddddddddddddddd",$format_wrap);
    $worksheet->write(2, 1, 2205,$format_top_center);
    $worksheet->write(3, 0, "Q2",$format_wrap);
    $worksheet->write(3, 1, 3305,$format_top);

    //$workbook->send('test1.xls');
    $workbook->close(); 
    ?>

I solved it by

我解决了问题

 chmod('/tmp/yXcel.ods',0777) 

Still, Any help would be much appreciated, Thank you !

尽管如此,我们还是非常感谢您的帮助,谢谢!

1 个解决方案

#1


1  

< Read-Only > Mode

<只读> 模式

Excel spreadsheets does not have "read only" mode. The main of Excel or LibreOffice reporting sheet as read-only are usually related to spread sheet file permissions (or ownership of that file) which may simply block writes but not reads. Once you download/copy the file to location owned by you should be able to edit it as well. If still not, ensure if file permission is not preventing it too.

Excel电子表格没有“只读”模式。作为只读的Excel或LibreOffice报告表的主要内容通常与扩展表文件权限(或该文件的所有权)有关,这些文件可能会简单地阻塞写,但不会读取。一旦你下载/复制文件到你拥有的位置,你也应该能够编辑它。如果仍然没有,确保文件权限没有阻止它。

#1


1  

< Read-Only > Mode

<只读> 模式

Excel spreadsheets does not have "read only" mode. The main of Excel or LibreOffice reporting sheet as read-only are usually related to spread sheet file permissions (or ownership of that file) which may simply block writes but not reads. Once you download/copy the file to location owned by you should be able to edit it as well. If still not, ensure if file permission is not preventing it too.

Excel电子表格没有“只读”模式。作为只读的Excel或LibreOffice报告表的主要内容通常与扩展表文件权限(或该文件的所有权)有关,这些文件可能会简单地阻塞写,但不会读取。一旦你下载/复制文件到你拥有的位置,你也应该能够编辑它。如果仍然没有,确保文件权限没有阻止它。