PHP Excel,但没有Spreadsheet_Excel_Writer

时间:2021-11-22 07:17:27

I need to save some data in .xls file. I am trying to use PEAR library Spreadsheet_Excel_Writer. It is work. But now i am working with hosting without PEAR. Of cause, it is very terrible.

我需要在.xls文件中保存一些数据。我正在尝试使用PEAR库Spreadsheet_Excel_Writer。这是工作。但现在我正在与没有PEAR的托管合作。原因,这是非常可怕的。

Spreadsheet_Excel_Writer has a lot of dependencies. I need a module or code, which i can include in my scripts.

Spreadsheet_Excel_Writer有很多依赖项。我需要一个模块或代码,我可以在脚本中包含它。

Thx.

5 个解决方案

#1


4  

I use Spreadsheet Writer a lot and it's nice to have, but if you don't need multiple sheets or the ability to do some formatting, etc, you an always just output HTML and send a

我经常使用Spreadsheet Writer,它很高兴,但如果你不需要多张工作表或能够做一些格式化等,你总是只输出HTML并发送一个

header("Content-type: application/vnd.ms-excel")

and an extension of ".xls" and then Excel or OpenOffice's spreadsheet program (and I assume, I guess, Mac's spreadsheet program) will open it and format the HTML as a spreadsheet.

和“.xls”的扩展,然后Excel或OpenOffice的电子表格程序(我猜,我猜,Mac的电子表格程序)将打开它并将HTML格式化为电子表格。

It's not a native solution but in the end, it looks pretty good to the end-user. You have to use tables in your html but you can add colors/borders, padding, font changes, rowspan, colspan, etc, for a bit of control. No functions or formulas or multiple sheets, though.

它不是本机解决方案,但最终对最终用户来说看起来不错。你必须在你的html中使用表格,但你可以添加颜色/边框,填充,字体更改,rowspan,colspan等,以进行一些控制。但是,没有功能或公式或多张表。

#2


4  

It's a little-known format that never really caught on, but MS Office has support for so-called Excel 2003 XML files - which are indeed XML and, at a bare minimum, look like this:

这是一个鲜为人知的格式,从未真正流行,但MS Office支持所谓的Excel 2003 XML文件 - 这些文件确实是XML,并且至少看起来像这样:

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
  <Worksheet>
    <Row>
      <Cell>
        <Data ss:Type="String">First</Data>
      </Cell>
    </Row>
   </Worksheet>
 </Workbook>

You could generate this quite simply without any PHP extensions, and it will open correctly in any version of MS Excel since 2003. OpenOffice 2 and 3 will open these correctly if you rename the file extension to .xls.xml

您可以非常简单地生成这个,没有任何PHP扩展,并且它将在2003年以来的任何版本的MS Excel中正确打开。如果您将文件扩展名重命名为.xls.xml,OpenOffice 2和3将正确打开它们。

When a user opens this file and saves it from Excel, it will be, by default, converted to the classic XLS file.

当用户打开此文件并将其从Excel保存时,默认情况下,它将转换为经典XLS文件。

As @Alexander.Plutov notes in a comment, there is a library for writing these files.

正如@ Alexander.Plutov在评论中指出的那样,有一个用于编写这些文件的库。

There's a useful (and more comprehensive) page on IBM's site about this format and PHP: http://www.ibm.com/developerworks/opensource/library/os-phpexcel/#N101F7

IBM网站上有一个关于这种格式和PHP的有用(且更全面)的页面:http://www.ibm.com/developerworks/opensource/library/os-phpexcel/#N101F7

#3


3  

Literally, PHPExcel: http://phpexcel.codeplex.com/

从字面上看,PHPExcel:http://phpexcel.codeplex.com/

#4


3  

Im using http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

我正在使用http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

I got it simply included in many projects and it works like a charm.

我把它简单地包含在许多项目中,它就像一个魅力。

#5


1  

Beware, the source code provided by Piskvor:

请注意,Piskvor提供的源代码:

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
  <Worksheet>
    <Row>
      <Cell>
        <Data ss:Type="String">First</Data>
      </Cell>
    </Row>
   </Worksheet>
 </Workbook>

is not a valid Excel file (at least in my version – Excel 2010) and will fail opening producing an error message, as it is missing two required values corrected in the following example (the missing part is that within a WorkSheet you need a Table and a WorkSheet must have a name specified as a string in ss:Name):

不是一个有效的Excel文件(至少在我的版本中 - Excel 2010)并且将无法打开生成错误消息,因为它缺少在以下示例中更正的两个必需值(缺少的部分是在工作表中需要一个表并且工作表必须在ss:Name中指定名称作为字符串:

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
   <Worksheet ss:Name="test">
     <Table>
       <Row>
         <Cell>
           <Data ss:Type="String">First</Data>
         </Cell>
       </Row>
     </Table>
   </Worksheet>
 </Workbook>

This then becomes a valid excel spreadsheet indeed and thanks to Piskvor for reminding us of this wonderful open and machine- and human-readable format.

这确实成为一个有效的excel电子表格,感谢Piskvor提醒我们这种精彩的开放,机器和人类可读的格式。

#1


4  

I use Spreadsheet Writer a lot and it's nice to have, but if you don't need multiple sheets or the ability to do some formatting, etc, you an always just output HTML and send a

我经常使用Spreadsheet Writer,它很高兴,但如果你不需要多张工作表或能够做一些格式化等,你总是只输出HTML并发送一个

header("Content-type: application/vnd.ms-excel")

and an extension of ".xls" and then Excel or OpenOffice's spreadsheet program (and I assume, I guess, Mac's spreadsheet program) will open it and format the HTML as a spreadsheet.

和“.xls”的扩展,然后Excel或OpenOffice的电子表格程序(我猜,我猜,Mac的电子表格程序)将打开它并将HTML格式化为电子表格。

It's not a native solution but in the end, it looks pretty good to the end-user. You have to use tables in your html but you can add colors/borders, padding, font changes, rowspan, colspan, etc, for a bit of control. No functions or formulas or multiple sheets, though.

它不是本机解决方案,但最终对最终用户来说看起来不错。你必须在你的html中使用表格,但你可以添加颜色/边框,填充,字体更改,rowspan,colspan等,以进行一些控制。但是,没有功能或公式或多张表。

#2


4  

It's a little-known format that never really caught on, but MS Office has support for so-called Excel 2003 XML files - which are indeed XML and, at a bare minimum, look like this:

这是一个鲜为人知的格式,从未真正流行,但MS Office支持所谓的Excel 2003 XML文件 - 这些文件确实是XML,并且至少看起来像这样:

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
  <Worksheet>
    <Row>
      <Cell>
        <Data ss:Type="String">First</Data>
      </Cell>
    </Row>
   </Worksheet>
 </Workbook>

You could generate this quite simply without any PHP extensions, and it will open correctly in any version of MS Excel since 2003. OpenOffice 2 and 3 will open these correctly if you rename the file extension to .xls.xml

您可以非常简单地生成这个,没有任何PHP扩展,并且它将在2003年以来的任何版本的MS Excel中正确打开。如果您将文件扩展名重命名为.xls.xml,OpenOffice 2和3将正确打开它们。

When a user opens this file and saves it from Excel, it will be, by default, converted to the classic XLS file.

当用户打开此文件并将其从Excel保存时,默认情况下,它将转换为经典XLS文件。

As @Alexander.Plutov notes in a comment, there is a library for writing these files.

正如@ Alexander.Plutov在评论中指出的那样,有一个用于编写这些文件的库。

There's a useful (and more comprehensive) page on IBM's site about this format and PHP: http://www.ibm.com/developerworks/opensource/library/os-phpexcel/#N101F7

IBM网站上有一个关于这种格式和PHP的有用(且更全面)的页面:http://www.ibm.com/developerworks/opensource/library/os-phpexcel/#N101F7

#3


3  

Literally, PHPExcel: http://phpexcel.codeplex.com/

从字面上看,PHPExcel:http://phpexcel.codeplex.com/

#4


3  

Im using http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

我正在使用http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

I got it simply included in many projects and it works like a charm.

我把它简单地包含在许多项目中,它就像一个魅力。

#5


1  

Beware, the source code provided by Piskvor:

请注意,Piskvor提供的源代码:

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
  <Worksheet>
    <Row>
      <Cell>
        <Data ss:Type="String">First</Data>
      </Cell>
    </Row>
   </Worksheet>
 </Workbook>

is not a valid Excel file (at least in my version – Excel 2010) and will fail opening producing an error message, as it is missing two required values corrected in the following example (the missing part is that within a WorkSheet you need a Table and a WorkSheet must have a name specified as a string in ss:Name):

不是一个有效的Excel文件(至少在我的版本中 - Excel 2010)并且将无法打开生成错误消息,因为它缺少在以下示例中更正的两个必需值(缺少的部分是在工作表中需要一个表并且工作表必须在ss:Name中指定名称作为字符串:

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
   <Worksheet ss:Name="test">
     <Table>
       <Row>
         <Cell>
           <Data ss:Type="String">First</Data>
         </Cell>
       </Row>
     </Table>
   </Worksheet>
 </Workbook>

This then becomes a valid excel spreadsheet indeed and thanks to Piskvor for reminding us of this wonderful open and machine- and human-readable format.

这确实成为一个有效的excel电子表格,感谢Piskvor提醒我们这种精彩的开放,机器和人类可读的格式。