I have a web page where a user can upload xls files. When he uploads a file, i want to automate converting the excel file to excel xml. I want to convert it to an xml file as i think it will be easy to handle the data.
Is it possible to write my own php function to do that?
Let me see if I understand. You're going to read a XLS file, write it out as XLSX, then read in the XLSX?
Why not just deal with the XLS in the first place?
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.
I would like to convert a txt file to excel and then modify certain data inside the excel file and then import this new excel file to a database using PHP. The contents of the excel file, for example, will be with products and prices of them and the modification will be on the prices.
Is this even possible using PHP or I will need something else?
Seems like a rather roundabout way of doing this, but I've had great success with Excel/php with phpExcel. That will get read/write Excel, but putting it into the database will likely require som php coding.
If you're just editing datas in Excell (no formulas ...) you should try csv format ...
I think that you should send a example of your txt file ...
Mimiz
In my application i am able to export data to CSV file successfully, But i need some contents of the CSV file to be in "bold" and "color".
So is it possible way to do it? If so please help me out.
If it is a valid option, you can export to Excel format using PHPExcel. This supports font color, weight etc..
The basic CSV file format doesn't have any way to represent such attributes. If the file is to be read by a specific application, maybe it supports a richer format that you can output in?
As others have said, you can not do it with CSV. But if your target program to read the CSV is Excel, you can create a XLS spreadsheet.
But I have had very good success using Spreadsheet_Excel_Writer: http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.php
Give it a shot.
CSV file is just comma separated values file so it can't be formatted. this is a simple text file with .csv extension. If you want to format then exporting into excel.
I need to implement a functionality where a user can upload an Excel file, that is, .xls file and i need to write a function that will read that file and then save the values in a table, compare them to values in another table and then print some kind of billing quotation.
From what I have read, it seems that the best way to do that is to first convert that file to an xml file and then write a function to parse that xml file.
I want to know, is it possible to write a function in php that will convert an xls file to xml. Assuming that the users will save and upload the file as xls.
Thanks.
i often let admin users upload a csv file they exported from an xcel file, its much simpler to parse through using http://php.net/manual/en/function.fgetcsv.php
A quick Google search for "PHP excel parser" turns up PHP Excel Reader, for an open source library to use for reading data from .xls files. There may be others that suit your needs.
I have been successfully using the 'ABC Excel Parser Pro' from Zakkis.
This allows converting from a XLS file directly into a MySQL table.
A few notes on limitations:
column count must match exactly to database columns
Excel 2007 format (xlsx) are not supported
My PHP script have to create a multi-tabs Excel file with a report in each tab, but those reports already exists as HTML pages, so I don't want to duplicate code and work.
I know I can rename a HTML file to .xls, and Excel/OpenOffice Calc will open it as a spreadsheet, but I don't know how to have severals tabs.
I do not even know if it is possible.
I already know Biffwriter and others PHP libs to create Excel file, but I am looking for a smarter solution.
Thanks,
Cédric
Pear Excel Spreadsheet Writer has a function to create new Worksheets if thats what you are looking for.
If you don't mind serving excel 2007 files, you can do this:
create an excel 2007 file
create all the tabs you need
save the file
rename the file as .zip
extract the contents of the zip file
Now you can use the file structure there to populate the file corresponding to each tab with the report you need. You may want to use them as templates, keep the same code and render different files depending on whether you generate the html report of the excel report.
In the end, zip up the entire directory structure and serve it with an xlsx extension.
Please check the URLS of
a library
and
turorials
from IBM and
from 999Tutorials