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.
Related
I would like to know is there a way which will help me convert a PDF which is not scanned (can be modified in Acrobat Pro) into a file which is scanned / flatted (cant be edited in Acrobat Pro).
I have been using FPDF library but it seems that it is not able to recognize if the PDF is flatten / not in 1st place and depending on this it is triggering some different actions.
I have tried my best to study the FPDF library and I think it checks for the 'xref' position and decides to take which steps should be taken.
But in my case I have 2 files, one is flatted and one not and FPDF cant determine the difference itself. Both these files are of version 1.4. I have also read that FPDF has a limitation of processing pdfs which are only 1.4 version.
You could use Ghostscript's pdfimage device which will render the entire content to an image, and then wrap that up as a PDF file. There's absolutely no possibility of extracting anything from that without running it through OCR software. That 'sounds lie' what you want, though its hard to be certain.
I'm afraid that I don't think your understanding of 'flattened' can be correct. All PDF files will have an xref, so the presence or absence of such a keyword doesn't tell you if the PDF is 'flattened', whatever your user/manager means by that rather vague term.
The absence of a 'xref' could mean that the file is a PDF 1.5 or better version, and is using a compressed xref. Nothing to do with it being flattened, but any PDF consumer will have to treat such a file differently to a PDF 1.4 or below file.
I am using php-excel-reader, but got error on reading .xlsx file. So does this support xlsx format. Or what is other solution available.
My requirement is just to read the file(xls, xlsx and ods) and render on html page.
PHPExcel seems too much as there is no requirement for editing the excel file.
Yes php support to read .xlsx file.
For that you have to use PHPExcel library.
I have created script to read excle file, You can download script from : https://www.dropbox.com/s/oao0eskflu8nyz1/PHPExcleReader.zip?dl=0
Judging from this issue it doesn't seem to work. They referr you to PHPExcel if you want to use xlsl files. From a first look, this seems like a better alternative anyways.
As far as I know php-excel-reader doesn't support xlsx. PHPExcel would be the way to go. That being said it might be better to store whatever is in your xslx files in a less proprietary way. Taking a long shot I would assume your xslx doesn't contain calculations which do belong in xlsx files but rather table data which would be better stored in some database (txt, csv, sqlite, a database server).
I have to develop one project in php and in that I have to include shape file and that shape file needs to be converted in to kml file.
I know how to convert shape file into kml file but I don't know how to take/import shape file into php project.
and I also have the supporting files with the shape file which contain more information.some of them are .dbf, .shx etc. And this all file's information should also be stored with the shape file information.
Is there any tool to import shape file or any other help so that I can add shape file into my project in php site?
or is it possible to store all the shape file(.shp), .dbf, . shx data into database and then use that data for the kml structuring.
I also want to know that,all shape files follow any structure or formatting?Is there any standard for the shape file
such as the xml file have?
xml file should have the starting tag mandatory.
They should follow the structure otherwise the viewer is unable to see the xml file.
UPDATE 2:
For v3.0.0 release, the library has been completely rewritten with an object-oriented approach: it now exposes some convenient ShapefileReader, ShapefileWriter and different kinds of Geometry objects (Point, MultiPoint, Linestring, MultiLinestring, Polygon and MultiPolygon).
It has been added support for custom charsets (CPG files), memo fields (DBT files) and, most importantly, it is now able to write shapefiles too!
At this point, it aims to be the most complete free and open source PHP library to read and write shapefiles out there and it's been used widely by many users in the last few years, but should you find any bug with it, please report it and/or open an issue and it will be promptly fixed.
UPDATE 1:
Since v2.0.0, PHP Shapefile is capable of reading Z and M shapefiles, natively access DBF, is PHP 7 compatible and much more. I am actively developing this, so feature requests are available.
I don't want to break any rule posting about my own library in an old question, but this page pops up in the firsts result when searching for php shapefile on Google, so I thought it might be useful for someone who is looking for such a library as I used to.
I've been looking for a decent library to import ESRI Shapefiles in PHP myself, and I ended up building my own. It can read all 2D shapefiles kinds of shapefiles and DBF data and it should be 100% bug free.
It's been used in production for a few months by now, so I made public release for anybody who would like to use it:
https://github.com/gasparesganga/php-shapefile
There are several PHP classes out there:
http://opensourcegis.org/ (search for PHP on this page)
http://www.phpclasses.org/package/1741-PHP-Read-vectorial-data-from-geographic-shape-files.html
http://nona.net/software/ext_shapelib/
Convert .shp files to an excel spreadsheet programmatically
And at least gis.stackexchange.com!
I'm currently using PHP with the PEAR extension, as well as the Spreadsheet_Excel_Writer package. I am able create a new excel file with PHP and save it to disk, but I can't find a stable Excel reader package.
Even if I do find a valid reader package I don't think this will be suitable as I want to be able to modify a complex excel document which contains its own formulas and graphs(on seperate spreadsheets) based on the content already saved in the data table.
Ideally, I'd like to enter data from the browser which will then, with PHP, modify only certain cells and then save the file again, the excel document itself will then update its own graphs etc. based on the modified data in the table.
Any ideas? Or have more experience with PEAR and know of packages for working with excel documents in this manner?
Thanx a lot!
You probably don't want separate reader and writer libraries, otherwise you're going to have to transfer all data between them manually, which limits you to libraries that can both read and write.
There's a comprehensive list of Excel libraries for PHP here
However, unless you use COM or PUNO, you'll have problems with graphs... even PHPExcel doesn't support charts yet, and (while planned for the the next release) will still only work with charts in OfficeOpenXML (.xlsx) files.
Let's say I've some data in cells A1-Ax from which I should get this data, process and write the result to the B1-Bx, C1-Cx and D1-Dx cells. Preferably using PHP.
You may want to look at PHPExcel.
(PHPExcel) provides a set of classes
for the PHP programming language,
which allow you to write to and read
from different file formats, like
Excel 2007, PDF, HTML, ... This
project is built around Microsoft's
OpenXML standard and PHP.
I think this is best when you have a large application written in PHP which handles excel files. I think this is not the best for very small changes.
Hope that helps.
PHPExcel is really good for reading/writing excel documents (and csv files).
Used it in a lot of projects, works really well.