I have a excel i need to add some more sheets into the excel using PHP, i have used PEAR, there i tried only can write excel and read a file, not able to read and modify the file, guys can you help me in this?
我有一个excel我需要使用PHP在excel中添加更多的工作表,我已经使用了PEAR,我尝试过只能编写excel并读取文件,无法读取和修改文件,伙计们,你能帮助我吗? ?
Thanks in advance
提前致谢
Prabu
Prabu
1 个解决方案
#1
12
You will need 2 pear packages
你需要2个梨包
- PHP-ExcelReader package
- PHP-ExcelReader包
- Spreadsheet_Excel_Writer package
- Spreadsheet_Excel_Writer包
What you need to do is read first the excel file use PHP-ExcelReader package It reads the binary format of XLS files directly and can return values and formats from any cell. http://code.google.com/p/php-excel-reader/
您需要做的是首先阅读excel文件使用PHP-ExcelReader包它直接读取XLS文件的二进制格式,并且可以从任何单元格返回值和格式。 http://code.google.com/p/php-excel-reader/
read the excel file
阅读excel文件
$data = new Spreadsheet_Excel_Reader("test.xls");
show the data of the file
显示文件的数据
$data->dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel')
Once you have stored the data in a variable save the data in another file this time you will use the The Spreadsheet_Excel_Writer package https://github.com/pear/Spreadsheet_Excel_Writer
一旦将数据存储在变量中,这次将数据保存到另一个文件中,您将使用The Spreadsheet_Excel_Writer包https://github.com/pear/Spreadsheet_Excel_Writer
<?php
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer('test.xls');
$worksheet =& $workbook->addWorksheet('My first worksheet');
if (PEAR::isError($worksheet)) {
die($worksheet->getMessage());
}
$workbook->close();
?>
#1
12
You will need 2 pear packages
你需要2个梨包
- PHP-ExcelReader package
- PHP-ExcelReader包
- Spreadsheet_Excel_Writer package
- Spreadsheet_Excel_Writer包
What you need to do is read first the excel file use PHP-ExcelReader package It reads the binary format of XLS files directly and can return values and formats from any cell. http://code.google.com/p/php-excel-reader/
您需要做的是首先阅读excel文件使用PHP-ExcelReader包它直接读取XLS文件的二进制格式,并且可以从任何单元格返回值和格式。 http://code.google.com/p/php-excel-reader/
read the excel file
阅读excel文件
$data = new Spreadsheet_Excel_Reader("test.xls");
show the data of the file
显示文件的数据
$data->dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel')
Once you have stored the data in a variable save the data in another file this time you will use the The Spreadsheet_Excel_Writer package https://github.com/pear/Spreadsheet_Excel_Writer
一旦将数据存储在变量中,这次将数据保存到另一个文件中,您将使用The Spreadsheet_Excel_Writer包https://github.com/pear/Spreadsheet_Excel_Writer
<?php
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer('test.xls');
$worksheet =& $workbook->addWorksheet('My first worksheet');
if (PEAR::isError($worksheet)) {
die($worksheet->getMessage());
}
$workbook->close();
?>