Log in

View Full Version : Create a word document from a search



Humper
12-18-2008, 09:03 PM
I need to create a word document from the results of a search... I have created the search Here (http://www.southernsinners.com/WDR/Tools/Search.php)... once on the results page of the search I need to be able to get the data that I want to put in the report and then be able to generate a word doc from that (there is a button called 'Create Report' that takes you to another page that should generate the word doc)..... I have created a word doc template to use to input the data into but this is where I get lost. (This is just a junk template.. mine will be different but this will at least show me what to do)

Here are the things I know:
I am using a linux server so I cant use COM.
I want to be able to create a new section for each 'WorkedTask' that is selected
The Highlight must be under the correct Task heading


Basically the only thing that anyone will select when creating a report is the task and highlight fields and this is all we care about when doing the weekly report. I have the other data in there to pull out for other reasons....


so say you search by Name and Date-- Ray Fossil and 12/31/08

You will get 2 different task and 3 different highlights... and say you check Training, Hello World, HHHWWWW1, TTTTT1, TTTTT2

so in the word doc... it needs to have two different sections
Hello World and Training

and under Hello World it needs to have the one highlight---- HHHWWWW1

and under Training it needs to have the two highlights---- TTTTT1, TTTTT2


can someone help me in figuring out how to accomplish this?

I have attached my code and the word doc

Jesdisciple
12-19-2008, 12:12 AM
Suggestion: Combine the two search pages (Search.php and Search_WDR.php) into one. This makes a new search easy and allows the user to refer to the old criteria - both without using the Back button. (According to usability best-practices, you should assume the Back button doesn't exist.)

Now for your question... I'm trying to get it straight; do you want to dynamically generate a Microsoft Word document? That will require some sort of library (as you obviously know); the only one I know of, and it works on Linux, is OpenOffice.org (http://www.openoffice.org/). I don't know if they have exposed an API for external applications, but I don't doubt it considering that OOo's a FOSS project.

Twey
12-19-2008, 10:27 AM
I have to wonder why you're doing this. The Microsoft DOC format, secret and proprietary as it is, is not well-supported, and changes markedly between even different versions of Office, let alone third-party products. If you want something to distribute files on the Web, where clients may be using any platform or software, it's not a good idea to restrict yourself so. If you really must use a word-processing document, ODF, an open standard supported by many office suites, is probably your best bet.

If you really must use Word, the best way of attacking the problem is most likely to write it in something like LaTeX and then convert (you can also offer a variety of formats, including the original LaTeX and the pretty-much-universal PDF, for those who can't easily work with Word documents for whatever reason [like yourself]).

Humper
12-19-2008, 02:36 PM
I will try an answer both your questions here....

Jesdisciple


Suggestion: Combine the two search pages (Search.php and Search_WDR.php) into one. This makes a new search easy and allows the user to refer to the old criteria - both without using the Back button. (According to usability best-practices, you should assume the Back button doesn't exist.)


How do you suggest I combine the two pages? iframe?



Now for your question... I'm trying to get it straight; do you want to dynamically generate a Microsoft Word document? That will require some sort of library (as you obviously know); the only one I know of, and it works on Linux, is OpenOffice.org. I don't know if they have exposed an API for external applications, but I don't doubt it considering that OOo's a FOSS project.


I need to create a dynamically generated document that can be edited if need be after it is created or I would try an create a PDF.... The server I am hosting this on is not my own and I don't know if they have OpenOffice installed...and I wont be able to install it.... I think I read yesterday that OpenOffice does expose an API for external applications though...



Twey


I have to wonder why you're doing this. The Microsoft DOC format, secret and proprietary as it is, is not well-supported, and changes markedly between even different versions of Office, let alone third-party products. If you want something to distribute files on the Web, where clients may be using any platform or software, it's not a good idea to restrict yourself so. If you really must use a word-processing document, ODF, an open standard supported by many office suites, is probably your best bet.


The document that they create the weekly reports in now is a Word document so thats what I was trying to stay with since they are use to useing a word document... When the user downloads the report I need the report to be formatted correctly and have the data that the searched inserted into the document...they also need to be able to edit the report if need be.... I will have to look into ODF as I have never used it before...



If you really must use Word, the best way of attacking the problem is most likely to write it in something like LaTeX and then convert (you can also offer a variety of formats, including the original LaTeX and the pretty-much-universal PDF, for those who can't easily work with Word documents for whatever reason [like yourself]).


As I have never used LaTex.. I would have to look into how I would accomplish this....




I was hoping there was an easy solution for creating a document that had some basic formatting and could be edited. Any other tip or suggestions are appreciated!!

Jesdisciple
12-19-2008, 06:42 PM
I just found this (http://sourceforge.net/projects/php-doc-xls-gen/), which is apparently written in PHP. If so, you should be able to install it.

EDIT: Oh, and you can combine the pages by setting the single page as its own form's action and using an if statement to decide whether to show the results (depending on whether the form was submitted).

Humper
12-19-2008, 07:08 PM
As the server I have the page on is paid hosting... I dont think I can install anything... I will look into this though.

Jesdisciple
12-19-2008, 07:26 PM
It's not an install per se... It's just uploading the PHP files to the server and including them (if it's pure PHP).

Humper
12-19-2008, 07:38 PM
I just downloaded and its just a php file.... I am going through it now to see if this is going to work for me...

Thanks

Humper
12-19-2008, 07:50 PM
I guess this is a start but it really has no function but to pull all data from a table and write it in a doc file.....

I need something that will allow me to have a template that it pushes data too... and that can dynamically create sections/pages... This just keeps getting more complicated.... lol

Jesdisciple
12-19-2008, 08:05 PM
You're right; that actually gets us no closer to the goal. I didn't pay enough attention to the summary.

Let's try this again: http://www.phpclasses.org/browse/package/2631.html

Humper
12-19-2008, 08:33 PM
looking at this one now..... this looks more a long the lines of what I need it to be able to do.... **crossing fingers**