Jump to content


Photo

Formatting for dynamically made XLS not working


  • Please log in to reply
1 reply to this topic

#1 ibanez270dx

ibanez270dx
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 10 August 2006 - 08:33 PM

Hi,
I have a portion of code that dynamically creates an XLS file - which works - and then it posts the information into the correct cells - which works. The problem is that only a bit of it actually formats correctly according to my code.

So the top bar (the column labels) works pretty ok. The bgcolor tag works and so does the text formatting in each cell. However, the width tag doesn't work - same with the style tag. Oddly enough, the bottoms of the cells are misaligned in every other cell.

Even a bigger problem, none of the tags in the second table (data) work, except the text formatting. I still need it to be vertically aligned in the middle, and the cell background be #e5e5e5 in every other cell.

Lastly, there are no gridlines when the file is opened... which seems really weird.

Here is my code:

$catanames = "
<table width=95% style=border: 1px solid; border-color:#000000;><tr>
<td bgcolor=#000000 width=100><font color=#FFFFFF><center><b>Type</b></center></font></td>
<td bgcolor=#000000 width=100><font color=#FFFFFF><center><b>Date</b></center></font></td>
<td bgcolor=#000000 width=100><font color=#FFFFFF><center><b>Downtime</b></center></font></td>
<td bgcolor=#000000 width=100><font color=#FFFFFF><center><b>Hours Down</b></center></font></td>
<td bgcolor=#000000 width=100><font color=#FFFFFF><center><b>ATA</b></center></font></td>
<td bgcolor=#000000><font color=#FFFFFF><center><b>Discrepancy</b></center></font></td>
<td bgcolor=#000000><font color=#FFFFFF><center><b>Resolution</b></center></font></td>
<td bgcolor=#000000 width=120><font color=#FFFFFF><center><b>Logged</b></center></font></td>
<td bgcolor=#000000 width=150><font color=#FFFFFF><center><b>Logged By</b></center></font></td>
</tr></table>";

 	 $data .= "
<table width=95%><tr>
<td bgcolor=#e5e5e5 width=100 valign=middle valign=middle><center>$dwntime_type</center></td>
<td width=100 valign=middle><center>$dwntime_date</center></td>
<td width=100 valign=middle bgcolor=#e5e5e5><center>$dwntime_times</center></td>
<td width=100 valign=middle><center>$dwntime_hrs</center></td>
<td width=100 valign=middle bgcolor=#e5e5e5><center>$dwntime_ata</center></td>
<td valign=middle><center>$dwntime_reason</center></td>
<td valign=middle bgcolor=#e5e5e5><center>$dwntime_solution</center></td>
<td width=120 valign=middle><center>$dwntime_log</center></td>
<td width=150 valign=middle bgcolor=#e5e5e5><center>$dwntime_log_by</center></td>
</tr><tr><td colspan=9><hr size=1></td></tr></table>";
	}

$fp = fopen($filename2,"a");
	if($fp)
	{

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

this ends up looking like:

Posted Image

Can anyone help me figure out why it won't format correctly?

Thanks!!
- Jeff

#2 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 11 August 2006 - 12:55 AM

Use double quotes in your style tag:
style="border: 1px solid; border-color:#000000;"
-the border tag should be coded:
style="border: 1px #000000 solid;"
Lose the width=95%:
<table style="border: 1px #000000 solid";>
-it fights with your width=100 and such for who rules




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users