Re: Convert HTML Table to Tab Delimited .TXT file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--- dpgirago@xxxxxxxxxxxxxx wrote:
> 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 

Mmaybe I'm missing something (quite possible), but you can make the
work happen autogically by using http headers.

header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=excelfile.xls");

Replace excelfile.xls with whatever you want the filename to be

Then write out your table as you would normally. the result should be
an excel file either downloaded or opened in the browser, depending
on the browser settings.


=====
Mark Weinstock
mark_weinstock@xxxxxxxxx
***************************************
You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing.
***************************************


	
		
__________________________________
Do you Yahoo!?
Yahoo! Domains ? Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux