Re: XML and Excel
| From: | Jake McHenry | Date: | Wed, 11 Feb 2004 06:18:38 +0000 |
| Subject: | Re: XML and Excel | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177348@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Phillip Jackson" <tzmguitarist@hotmail.com>
To: "Jake McHenry" <linux@nittanytravel.com>
Sent: Tuesday, February 10, 2004 4:53 PM
Subject: Re: [PHP] XML and Excel
> sure; if it doesn't compromise security for you.
>
>
> ~Phillip
>
>
> ----- Original Message -----
> From: "Jake McHenry" <linux@nittanytravel.com>
> To: "Phillip Jackson" <tzmguitarist@hotmail.com>
> Cc: <php-general@lists.php.net>
> Sent: Tuesday, February 10, 2004 1:45 PM
> Subject: Re: [PHP] XML and Excel
>
>
> > I implemented the classes found at the link he provided, followed the
> > directions in the readme and examples
> >
> > do you want me to post the code as well?
> >
> > thanks,
> > Jake
> >
> >
> > ----- Original Message -----
> > From: "Phillip Jackson" <tzmguitarist@hotmail.com>
> > To: <php-general@lists.php.net>
> > Sent: Tuesday, February 10, 2004 11:35 AM
> > Subject: Re: [PHP] XML and Excel
> >
> >
> > > Please post your solution to the group for reference.
> > >
> > > ~phillip
> > >
> > > "Jake McHenry" <linux@nittanytravel.com> wrote in message
> > > news:00de01c3ef49$fcba6170$7fa1e518@JS...
> > > > ----- Original Message -----
> > > > From: "Marek Kilimajer" <kilimajer@webglobe.sk>
> > > > To: "Jake McHenry" <linux@nittanytravel.com>
> > > > Cc: <php-general@lists.php.net>
> > > > Sent: Monday, February 09, 2004 12:42 PM
> > > > Subject: Re: [PHP] XML and Excel
> > > >
> > > >
> > > > > Create native xls files, there are at least two classes that can
> help
> > > > > you, here is one:
> > > > >
http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/
> > > > >
> > > > > Jake McHenry wrote:
> > > > > > Hi everyone. Since my last post of outputing to excel, I have
> > > converted
> > > > my output to XML, quite happy with myself. It looks perfect. Perfect
> on
> > my
> > > > set that is. I have win xp with office xp. Excel with office xp
> > recognizes
> > > > XML. Office 2000, which the rest of my company is using, doesn't.
Does
> > > > anyone know of a way I can take the XML I have now and have office
> 2000
> > > > recognize it? I feel kinda stupid... lol Sent out an email to my
> > > accounting
> > > > department saying it was ready for them and all they get is garbage
on
> > > their
> > > > screen.
> > > > > >
> > > > > > Anyone know of anything I can do?
> > > > > >
> > > > > > Thanks,
> > > > > > Jake
> > > > >
> > > >
> > > > sweet.. thanks a lot.. took me about 3 hours, but I got it all
> > converted.
> > > > works great!
> > > >
> > > > Thanks again,
> > > > Jake
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
>
Here's the basics... I have some while loops in there too.. where the index
variable is used.. but this is what was added for the excel output.
Jake
require_once "/var/www/excel/class.writeexcel_workbook.inc.php";
require_once "/var/www/excel/class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "timesheet.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet = &$workbook->addworksheet();
// header format
$header = &$workbook->addformat();
$header->set_bold();
$header->set_underline();
$header->set_align('center');
// notes format
$notes = &$workbook->addformat();
$notes->set_bold();
// dollar format
$dollar =& $workbook->addformat();
$dollar->set_align('right');
$dollar->set_num_format('$ ###,##0.00');
// number format
$number =& $workbook->addformat();
$number->set_align('left');
$number->set_num_format('###,##0.00');
$worksheet->set_column(0, 0, 20);
$worksheet->set_column(1, 1, 20);
$worksheet->set_column(2, 2, 8);
$worksheet->set_column(3, 3, 8);
$worksheet->set_column(4, 4, 8);
$worksheet->set_column(5, 5, 8);
$worksheet->set_column(6, 6, 8);
$worksheet->set_column(7, 7, 8);
$worksheet->set_column(8, 8, 8);
$worksheet->set_column(9, 9, 8);
$worksheet->set_column(10, 10, 5);
$worksheet->set_column(11, 11, 7);
$worksheet->set_column(12, 12, 7);
$worksheet->set_column(13, 13, 7);
$worksheet->set_column(14, 14, 7);
$worksheet->set_column(15, 15, 5);
$worksheet->set_column(16, 16, 8);
$worksheet->set_column(17, 17, 10);
$worksheet->write(0, 0, "NAME", $header);
$worksheet->write(0, 1, "LOCATION", $header);
$worksheet->write(0, 2, "REG", $header);
$worksheet->write(0, 3, "VAC", $header);
$worksheet->write(0, 4, "SICK", $header);
$worksheet->write(0, 5, "COMP", $header);
$worksheet->write(0, 6, "MISC", $header);
$worksheet->write(0, 7, "W/O PAY", $header);
$worksheet->write(0, 8, "SEM/FAM", $header);
$worksheet->write(0, 9, "TOTAL", $header);
$worksheet->write(0, 10, "ADJ", $header);
$worksheet->write(0, 11, "BONUS", $header);
$worksheet->write(0, 12, "POST", $header);
$worksheet->write(0, 13, "EMP. A/R", $header);
$worksheet->write(0, 14, "PRE", $header);
$worksheet->write(0, 15, "401K", $header);
$worksheet->write(0, 16, "RATE", $header);
$worksheet->write(0, 17, "GROSS", $header);
$worksheet->write($index, 0, "$fullname");
$worksheet->write($index, 1, "$location");
$worksheet->write($index, 2, "$regularhours");
$worksheet->write($index, 3, "$vachours");
$worksheet->write($index, 4, "$sickhours");
$worksheet->write($index, 5, "$comphours");
$worksheet->write($index, 6, "$mischours");
$worksheet->write($index, 7, "$wopyhours");
$worksheet->write($index, 8, "$sefahours");
$worksheet->write($index, 9, "$biweekly[0]");
$worksheet->write($index, 10, "$adjustedtime", $number);
$worksheet->write($index, 15, "$sub401k", $number);
$worksheet->write($index, 16, "$payrate", $dollar);
$worksheet->write($index, 17, "$gross5", $dollar);
$worksheet->write($index2, 17, "$overallgross", $dollar);
$worksheet->write($index3, 0, "NOTES:", $notes);
$worksheet->write($index4, 0, "ANY QUESTIONS OR COMMENTS PLEASE CALL ",
$notes);
$workbook->close();
header("Content-Type: application/x-msexcel");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);