Home > Archive > PHP DB > May 2004 > Convert HTML Table to Tab Delimited .TXT file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Convert HTML Table to Tab Delimited .TXT file
|
|
| dpgirago@mdanderson.org 2004-05-24, 12:32 pm |
| Howdy All,
I've PHP / apache / MySQL running on a Linux machine where a GUI allows an
administrator to track changes made to computers on our intranet. I've
been asked to add an 'history' button so that all changes made to one or
more computers can be put into a table, displayed on client machines
(windows), then imported into an excel spread sheet. So far so good. I'm
querying the dB, retrieving the requested records, then displaying in a
new window in a table with border set to '0'. The expectation is that the
admin on a client machine will then copy the table to a text file, then
import into excel.
The problem is with the field separator. I tried concatenating a '\t' to
each field but this didn't behave as expected. Eventually, I concated a
'|' (bar) character, and this imported with the correct formatting.
However, now there is this foreign character at the end of each cell in
the spread sheet.
My question is whether there might be a more direct way to get the dB data
into excel on the client PC (can't imagine how), or if not, how I might
create a 'tab delimited' file from the HTML table and avoid introducing a
foreign character as a field separator.
Thanks for reading this long post.
dave
| |
| Torsten Roehr 2004-05-24, 12:32 pm |
| <dpgirago@mdanderson.org> wrote in message
news:OFD9782EDE.9DCA2F68-ON86256E9E.004B834E-86256E9E.004F4E26@mdacc.tmc.edu
....
> Howdy All,
>
> I've PHP / apache / MySQL running on a Linux machine where a GUI allows an
> administrator to track changes made to computers on our intranet. I've
> been asked to add an 'history' button so that all changes made to one or
> more computers can be put into a table, displayed on client machines
> (windows), then imported into an excel spread sheet. So far so good. I'm
> querying the dB, retrieving the requested records, then displaying in a
> new window in a table with border set to '0'. The expectation is that the
> admin on a client machine will then copy the table to a text file, then
> import into excel.
>
> The problem is with the field separator. I tried concatenating a '\t' to
> each field but this didn't behave as expected. Eventually, I concated a
> '|' (bar) character, and this imported with the correct formatting.
> However, now there is this foreign character at the end of each cell in
> the spread sheet.
>
> My question is whether there might be a more direct way to get the dB data
> into excel on the client PC (can't imagine how), or if not, how I might
> create a 'tab delimited' file from the HTML table and avoid introducing a
> foreign character as a field separator.
A comma seperated values file (.csv) should be readable by Excel. Just put a
; between all values and save it as a text file with .csv extension. I think
you don't need to go all the way via HTML output and copy/paste.
Hope this helps.
Regards, Torsten Roehr
| |
| Chris Berlioz 2004-05-24, 12:32 pm |
| An easy way to do it (work around) is to dump it as csv or html. If your
form can output an html table to the browser to show results then all you
need is to include a short instruction on the html form that has all results
in html table that would say something like "Save with your browser's 'save
as' button and save it as a HTM file then open it with Excel"
Then the user would easily open an HTML file in XLS and do what ever they
want with it (save as XLS, WK*, etc.... It gets more complicated if you
want to use formulas in the spreadsheet but if its just raw data this would
be a very easy way to accomplish what you want. Hope this helps.
Christian.
|
|
|
|
|