[resolved] Importing to Excel

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ibanez270dx
Forum Commoner
Posts: 74
Joined: Thu Jul 27, 2006 12:06 pm
Location: Everywhere, California

[resolved] Importing to Excel

Post by ibanez270dx »

Hi,
I am seriously at my wit's end about this... I need to be able to click a link, which opens up a dynamically created Excel page with X number of rows and 9 columns. I am currently using a script called "excelwriter", but I can't seem to get it to work properly - that is, write all the rows into the excel file (I can only write one, which is a little useless...). So, my question would be: How would I be able to accomplish this if I rewrote the whole script? I'm talking from scratch... Also, is it possible to import my data as an HTML table to Excel? I think that would be easiest.

Thanks in advance,
- Jeff
Last edited by ibanez270dx on Thu Aug 10, 2006 5:46 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Are you referring to the PEAR Excel Writer class? the documentation for it has examples of specifying where to place output.
ibanez270dx
Forum Commoner
Posts: 74
Joined: Thu Jul 27, 2006 12:06 pm
Location: Everywhere, California

Post by ibanez270dx »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


no, I was using a script called "ExcelWriter" by Harish Chauhan. Anyhow, I have switched to now exporting my data as a CSV. However, I just can't format it. Does anyone know how to add formatting (like bold text, etc...) into a CSV? Whenever I try using HTML tags, it just prints the tags.

Here is my current code:

Code: Select all

$cr = "\n";
$xojet = "TITLE" . ',' . $monthname . ',' . $year . $cr;
$catanames = 
"Type" . ',' . "Date" . ',' . "Downtime" . ',' . "Hours Down" . ',' . 
"ATA" . ',' . "Discrepancy" . ',' . "Resolution" . ',' . "Logged" . ',' . 
"Logged By" . $cr;
 	 
$data .= 
$dwntime_type . ',' . $dwntime_date . ',' . $dwntime_times . ',' . 
$dwntime_hrs . ',' . $dwntime_ata . ',' . $dwntime_reason . ',' . 
$dwntime_solution . ',' . $dwntime_log . ',' . $dwntime_log_by . $cr;
	}

$fp = fopen($filename2,"a");
	if($fp)
	{
	 fwrite($fp, $title);
	 fwrite($fp, $catanames);
	 fwrite($fp, $data);
	 fclose($fp);
	 echo "File saved successfully. <a href=$filename.csv>click here to access $filename2</a>";
	} else {
	 echo "Error saving file!";
	}

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Does anyone know how to add formatting (like bold text, etc...) into a CSV?
Can't do it. CSV is values in a 2 tier structure, nothing else.
Whenever I try using HTML tags, it just prints the tags
Somewhat predictible.
no, I was using a script called "ExcelWriter" by Harish Chauhan
That sounds like your problem right there :P
ibanez270dx
Forum Commoner
Posts: 74
Joined: Thu Jul 27, 2006 12:06 pm
Location: Everywhere, California

Post by ibanez270dx »

Yeah, I actually dumped the idea and went with using simple tables. Thanks for the help, though!
Post Reply