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).
Related
I need a phpspreadsheet code for reading data from csv file using vlookup and then writing it to multiple xlsx file depending on the criteria
Example:
Reading from this file
source
Getting output like this:
output
I might recommend the PhpSpreadsheet library, it's free and has great documentation on how to do this exact sort of thing.
Is there any way to format the cells of a csv file with php ? For instance , i have a csv file that i need to format its cell's size before i export it.And another thing is that for numbers with many digits,the excel shows it in another format before i dobule click it and i want to get rid of this too.
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=export.csv');
I know that i have to show what i have already tried,but i couldn't find any information about this,so i have nowhere to begin...
EDIT: The file is csv but i use it as an excel file,and the excel cells are the ones that need to be formated
CSV format consists of nothing more than raw values; there is no way of storing formatting or data type information. Which is why most, if not all, spreadsheet apps let the user manually set column types when importing a CSV file.
If you want to spare your users the hassle of doing that, your best bet would be generating an xls/xlsx rather than CSV. PHPExcel is a popular PHP library for generating Excel files, you might want to give it a try.
Since the accepted answer was written in 2014, the PHPExcel library has been abandoned. It's last version, 1.8.1, was released in 2015. It was officially deprecated in 2017 and permanently archived in 2019. It's direct successor is PhpSpreadsheet.
PHP can parse a CSV string into an array by using str_getcsv (http://php.net/str_getcsv). From there it's simply a matter of editing the values of the array.
As for more advanced features, the CSV format in itself does not support them since it's a pure text format and neither PHP nor the CSV file can decide how Excel should parse the file.
I've had success with exporting Excel XML files (the old, pure text XML files; not the new, zipped ones) and if data presentation is important for you, this might be the way to go.
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.
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.