Creating Excel file via PHP - php

For creating DOCX files, I'm using phpdocx's software which is working great.
But now I need to create XLSX files via PHP. The data is input via many forms and need to create corresponding Excel files with multiple sheets and graphs etc etc.
Is there any tool (including paid one) out there that can generate Excel files via PHP ?
The closest I'm come across is this - PHPExcel but this is now forwarded to PhpSpreadsheet, which is not yet released.

Related

How to fill data to template excel by php without api

I have some problem using phpexcel api.
this api is taking to long to fill data to exist template excel.
so, I want to write by pure php without using any api.
I want to know how to fill data to template excel by pure php.
Please give me some advise. Thanks :)
Old xls files were proprietary binary file formats, quite complicated, also known as Excel BIFF, you can find
reverse engineered specification here: http://www.openoffice.org/sc/excelfileformat.pdf
Microsoft's public specification here: [MS-XLS]: Excel Binary File Format (.xls) Structure (PDF) and here: [MS-XLS]: Excel Binary File Format (.xls) Structure (HTML)
New xlsx files are "standardized" open formats. It is basically a zip file (rename it to *.zip and extract) with few xml files inside
Some general information is available at http://en.wikipedia.org/wiki/Office_Open_XML
More detailed documentation is available from
MSDN: Office → Dev Center → Open XML SDK → Understanding the Open XML file formats
and from Ecma International → Ecma Office Open XML File Formats Standard
Still even the new file format is quite complicated if you want to be able to do everything or anything. In that case reusing several man/years of development effort (including debugging) materialized in a form of an existing PHP library as suggested by #mark-baker is reasonable
If you just need to do a specific task, e.g. populate existing xlsx template file with some data then you only need
a PHP functions for copying files
a PHP functions to work with zip files
and a PHP functions to work with xml files
and the documentation (from the links above) or an executable documentation in a form of Excel.exe
EDIT better links to the specification both for the old and for the new Excel file formats were provided by Mark Baker

Best way to import large amounts of data (Csv vs xls vs xlsx vs ?)

I have a php application that needs to work on many configurations of php with as little requirements outside of the code igniter framework as possible.
I have an import function right now that uses .csv files. Csv is pretty good as if is cross platform. But people have trouble with it when using excel. It also can't display chiense characters correctly.
Then there is .xls and .xlsx files. There are libraries for these but often require php_zip
What option should I choose that works with many php installs and is good for display and import?
there may be chances of information lost in the export to CSV.
It will only save the values of the cells - not their formatting informations.
There's no way you'll read an .xlsx file without unzipping it, which means you'll need a zip lib.
PHPExcel handles several formats of excel files, but it can be a bit resource hungry.
http://phpexcel.codeplex.com/
XLSX2CSV is less resource intensive, but only reads one page of multi-page worksheets, doesn't read parse formulas and doesn't handle .xls files.
http://davidacollins.com/weblog/xlsx2csv

converting a given file to PDF

hey all,
is there any way to convert a given file (this could be of any type) in to a pdf file in .net or php?
eg: suppose there is a upload link to upload your file of any type(word,excel,autocad,images..) and once the upload button is clicked the uploaded file should be converted into a pdf.
i checked out fpdf.but according to my knowledge all file types cannot be converted.a module to plugin to the CMS would also be fine.
FPDF does support images. I know because I have used it recently.
If you are wanting a pure PHP solution, you can use the PHP COM functions along with Word or Excel on the server to open up those files then copy the data out.
If I were you though, I would use Google. Load the doc into Google Docs then export it as a new format with the API.
There are a couple of 3rd party solutions available such as this one, which is optimised for use on the server and accessible from any web services capable environment, including .net. Supports loads of file types including MS-Office based documents.
Disclaimer, I worked on this product so consider me biased. Having said that, it works very well.

How to insert/embed images in dynamically generated MS Excel file using PHP?

I need to export a report to Excel file using PHP i.e. on the fly. I am actually getting data from MySQL and presenting it in HTML tables.
I am able to export all this data into Excel file format, except images. I can't point the image source to an absolute URL, because this file also needs to work off-line.
Is there any way I can embed/insert images into this Excel file without using any library i.e. only PHP code or library which doesn't require PEAR/PECL extensions. I am using LAMP stack, so COM is not an option.
I'm not sure what your reasoning is for not using PEAR, but there is a modified version (PHP Excel Creator library) of PEAR Spreadsheet Excel Writer which does not have any dependencies on the rest of PEAR.
I know that the original PEAR version has a method Worksheet::insertBitmap() . You would need to convert the images to bitmap if they aren't already (maybe using GD
in PHP)
If you are on Windows and have decent access to the server you could also try using COM to talk to Excel and generate the file that way.

What is the best way to process all versions of MS Excel spreadsheets with php on a non-Windows machine

I am importing data from MS Excel spreadsheets into a php/mySQL application. Several different parties are supplying the spreadsheets and they are in formats ranging from Excel 4.0 to Excel 2007.
The trouble is finding a technique to read ALL versions.
More info:
- I am currently using php-ExcelReader.
- A script in a language other than php that can convert Excel to CSV would be an acceptable solution.
Depending on the nature of your data and the parties that upload the excel files, you might want to consider having them save the data in .csv format. It will be much easier to parse on your end.
Assuming that isn't an option a quick google search turned up http://sourceforge.net/projects/phpexcelreader/ which might suit your needs.
The open-source ETL tool Talend (http://wwww.talend.com) will generate Java or Perl code and package such code with the necessary 3rd party libraries.
Talend should be able to handle all versions of Excel and output the result set in any format you require (including loading it directly into a database if need be).

Categories