How can i format the excel report though php application
I am able to generate the excel report in php but how can i do the formatting changes in the excel.
eg. I have to add image in excel.
Red borders to columns.
some background color to excel
Change the font color
Help appriciated
I don't think it is directly possible without any libraries.
Have a look at PHPExcel, You will be able to do what you are looking for.
Credits to Mark Baker.
Tougher Way
You will need to generate XHTML from your Excel document, After that you need to search and parse for tags and do your formatting and stuff.
Related
I'm using code from http://forums.codeguru.com/archive/index.php/t-470940.html to create excel in php. Is there a way to add styles like bold and/or italic to cells when doing it that way? Thank you
The method shown in that thread does not generate an Excel .xls file. It generates a tab-separated-value file. This is a plain text format, that does not support styling of any kind
If you want to generate a real xls file with formatting, then look at some of the libraries that can be used from PHP to write actual Excel files such as my PHPExcel library
EDIT
In addition to PHPExcel, you can find details of other PHP libraries for writing real Excel files in the answer to this question
Somebody knows a tool or framework that able me to generate the same report in HTML, PDF and Excel with the same effort?
I know about PHPExcel or FPDF, but I don't wanna write and mantain many outputs. I want to have just one effort and have many outputs.
Thanks,
Armando
You have to define a common representation for all your outputs.
For example, you can take HTML and then find tools like DOMpdf that convert it in PDF.
You can also open HTML documents with MS Excel. Depending on your styles, it could break up your document though.
Hi everybody
I'm using CKeditor to edit and generate some reports for my php project. But I need to export the edited texts from CkEditor to Open office and Microsoft word format. So what I need is a class or component which has a function like these :converttoodf($htmlcode) converttodoc($htmlcodes) which return odf and doc format.
However, The doc and Odf file should be without problem , and the pictures and tables should be shown nicely.
In addition, No matter if yr solution be commercial, I may buy it cause I really need it urgently
Tnx in advance and hope can get the right answer asap , here
XLS:
http://docraptor.com/ (automatic conversion from HTML)
or
http://phpexcel.codeplex.com/ (manual building of file, just like phpword from another answer)
DOC
You can get away with just saving the HTML with inline css styles applied and saving it as a .doc. Not sure about how to display images there though.
ODT
http://incubator.apache.org/zetacomponents/documentation/trunk/Document/tutorial.html
more info: http://www.slideshare.net/tobyS/presentation-5028656
You might want to take a look at phpword... i know it supports html documents but im not sure if you can jsut load some source and save it out - you may have to build the document programatically.
If you need ODT anyway, then I'd recommend using OpenOffice via commandline. There is http://www.artofsolving.com/opensource/pyodconverter which can convert between pretty much all Office formats.
HTML import shouldn't be a problem. Don't be foiled by the PDF example. Input and output formats can vary. http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.html
I am generating a simple csv file using php. The file contains some user's personal data.
When I open the generated file in office, the addresses are not displayed in full height. I have to double click on the cell for the address to be shown fully (in full width and height) otherwise I can only see the first word/number of the address.
Also, I have date of births displayed as ######, I have to expand the whole column to see them fully.
This doesn't happen in open office.
Is there any way to force MS Office to show all fields in full? Because otherwise it'll be to confusing for the people who will use (Hey where are all the details!:)
Thanks :)
I don't think you can "format" your sheets with CSV. You will have to produce some other file format that Excel understands. I would suggest XML which is really easy to generate.
Just make a sample sheet with the data you want, save it as XML and you'll see how your file should be generated.
Or you could use some ready-made PHP solution for writing excel files if you can't be bothered with analysing the XML file.
you could try the auto-size columns feature.
This is a UI issue with how Excel works, you can't force Excel or anything else how they handle it.
The quickest work around is to perhaps create an XLS file that runs a macro to retrieve the CVS file and format the cells as needed, but there's nothing you can do inside the CSV to affect what Excel is displaying.
INTRODUCTION
I'm using excel downloads as a way of users downloading a score sheet,
filling out scores and then re-uploading this score sheet into the
system.
Part of this requires the data in the database to be put into a CSV.
Then its opened on the client computer.
PROBLEM
The problem I'm having is that the CSV does not allow me to use any
kind of formatting. This includes hiding cells, making text bold etc.
So parsing the data in and out of an excel format (xls) document would
make more sense... But from what I've heard and read, this would be
really difficult because of different excel versions etc etc.
QUESTION
I heard that XML is a good way of parsing data into an excel format.
I wondered if anyone had any experience of this using php?
Is there a good script anyone has heard of?
Does anyone have any comments on different versions of excel opening
ir (or even, things like open office or lotus)
What do you think if my best step forward?
Thanks very much for your help!
Either reply or email me
tom at candid sky dot com
Try out PHP Excel (not sure if both links are the same) and PHP Excel Reader.
I'm sure there are, for example, Perl modules which would help with XML, but consider also that an HTML table: <tr>, <td>, <th> tags will be opened by Excel and at least some of the formatting will translate to Excel
you just have to name it ... something.xls