Jump to content

Archived

This topic is now archived and is closed to further replies.

ibanez270dx

Formatting for dynamically made XLS not working

Recommended Posts

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:

[code=php:0]
$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!";
}
[/code]

this ends up looking like:

[img]http://www.loaded-designs.com/images/excel.gif[/img]

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

Thanks!!
- Jeff

Share this post


Link to post
Share on other sites
Use double quotes in your style tag:
[code]style="border: 1px solid; border-color:#000000;"[/code]
-the border tag should be coded:
[code]style="border: 1px #000000 solid;"[/code]
Lose the width=95%:
[code]<table style="border: 1px #000000 solid";>[/code]
-it fights with your width=100 and such for who rules

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.