I want to modify a already existing excel sheet using PHP.
I tried to use pear class Spreadsheet_Excel_Writer.But this class is used to entirely create a new excel sheet and write in it.
Is there some way i can modify the already existing excel sheet using PHP?
I do believe, that PHPExcel class can help you out, but you may have to do a read and then a complete rewrite to another spreadsheet. I do not know, if the class allows for just modification.
A good solution for this is contained in PHPExcel... but... one can not modify an existing file. You have to open it, read the data, and write the modified data while creating a new excel file.
Its very good documented, accessing the data is very easy. A whole separate documentation is made for reading spreadsheet files.
Related
I tried to find some append method in the Writer class, but I found nothing.
Maybe is there a simple workaround, or should I just read the existing file and create a new one to append into?
There is no way to directly append rows to a spreadsheet. You are right though, the solution is to read the entire spreadsheet and create a new one with the appended rows.
The reason for that is that Spout does not store an in-memory representation of the spreadsheet but works line by line.
You can find an example for this use case here: https://opensource.box.com/spout/guides/add-data-to-existing-spreadsheet/
I need to generate Word document using PHP. I have html, save it as doc-file, but now I need to insert in this file excel table. How can I do it with html content, or I need some classes to do it?
There is an excellent PHP class for creating Excel documents. It is called php-export-data by Eli Dickinson, http://github.com/elidickinson/php-export-data.
Also you can check this stackoverflow question: Alternative for PHP_excel
However, this is some sort of advanced task, you better be prepared.
I'm exporting data in excel sheet via drupal view. Drupal views_export_xls module uses
http://code.google.com/p/php-excel/source/browse/branches/class-excel-xml.inc.php?r=9
library to export data into excel sheet. Every thing working fine. But i want little more from it.
How to add MACRO in excel sheet row or cell programmatically?
Is it possible to do so by php code?
If you look at above link - line no 88 & 93 which actually create cells and rows.
What i want to create a macro and place it on excel sheet that can later convert this generated excel file into native xml (.in) file for business purpose.
I've searched a lot but most of the link suggesting VB solution and i've no sense about this language.
Can anyone point me on right direction.
Any help would be greatly appreciated!
As far as I'm aware, unless the Excel writer that you're using is based around COM, then there is no way of creating a Macro in an Excel workbook.
There is one excel sheet which contains student name, rollno etc. How can i parse the contents of excel file and store that in my sql database?
You are looking for PHPExcel library i believe.
http://phpexcel.codeplex.com/
use this class to read the excel files
http://sourceforge.net/projects/phpexcelreader
If you want to do it directly from the Excel file, rather than create an intermediate CSV using Excel's "Save As" options, then look at libraries such as PHPExcel that can read the xls binary format and make the data accessible to your PHP script.
I'd recommend to you that you save it as csv, it's much more easier and less hacking to upload it to the database
here is simple a sample
http://www.bradino.com/php/csv-upload-to-database/
PHPExcel is one of the best PHP classes i have ever worked with. In addition to parsing and reading files of all Excel variations (including csv) the output to Excel 2007 + is excellent.
Be sure to look at the documentation and examples...they will get you up to speed very quickly
I'm creating Excel files in a PHP project. Those files aren't just CSV data... They are multiple tabs spreadsheets with functions and formatting.
So far I'm using the Spreadsheet_Excel_Writer class that is provided with Pear.
Everything is fine but our users don't like 2 things:
When they open those files generated by PHP, modify them with Excel and save those changes, Excel ask to upgrade the file format because it was saved to version 5.0/95.
Files are way too large because of the embedded images. As far as I know the only way to add images with Spreadsheet_Excel_Writer is with insertBitmap which add 24 bit bitmaps to the document.
I would like to address those issues. I'm pretty sure #1 can't be done as you can see there. But is there a way to add compressed images (jpeg) to the document?
If it's not possible to modify Spreadsheet_Excel_Writer to meet my needs, what are your class recommendations for this? Searching questions here leaded me to PHPExcel. Are there any other good alternatives out there?
If possible I would like to stick with Spreadsheet_Excel_Writer because changing to another class would be much more work (those generated spreadsheets are quite complex).
I'm using PHP 5.2.9.
I ended up using PHPExcel. With this class I can avoid point #1 since I can save in may formats (including Excel 2003/2007). For point #2 it's possible and PHPExcel do this already. When you chose the old Excel format, PHPExcel extends Spreadsheet_Excel_Writer in order to save the file.
It was a pain to rewrite my the code to use the new class but it was worth it since PHPExcel is really nice.
I've done this with PHP using XML for the spreadsheets. Check out this link for the XML spreadsheet: http://msdn.microsoft.com/en-us/library/aa140066(office.10).aspx and http://blogs.msdn.com/dmahugh/archive/2006/12/10/images-in-open-xml-documents.aspx for inserting images.