From: Mark W. <ma...@rw...> - 2011-10-07 22:30:34
|
I have done a bit of googling, and I have come across a library called PHPExcel. It looks awesome. The project page is here: http://phpexcel.codeplex.com/ download here: http://phpexcel.codeplex.com/releases/view/45412#DownloadId=212184 Extract it to a folder in your html directory and then run some of the test files. The API looks like it is really easy to use, and it produces proper xls /xlsx files even pdf's! Please let me know your thoughts! Mark _____________________________________________ Mob: 07725 695178 Email: ma...@rw... On 07/10/2011 18:23, paul cooper wrote: > heres how i do it in perl > > it reads the data from ts-times and then puts them in hash of a hash > with the main key , the starttime ( in seconds) > the data can then be sorted on time by sorting the key > > it then loops through the array of sorted times (%dh) > and makes a string of the values of the hash and writes it to a file > the file can then be then imported into spreadsheet and the the > data parsed using text to columns function in the spreadsheet > As i only have to do this 1-2 times /yr I do it manually each time. > there are a few random variables and functions from extracting data > for other things > > someone who knows more perl could probably tidy it up by passing > hashes by reference > > its a bit of kludge but it does what i need it to . > > > #!/usr/bin/perl -w > use strict; > use Date::Manip; > use warnings; > > use Data::Dumper; > use DBI; > use CGI; > > my $dbh;my $sth; > > my @holidays > =('20110103','20110422','20110425','20110429','20110502','20110530','20110829','20111226','20111227'); > my ($DAY, $MONTH, $YEAR) = (localtime)[3,4,5];#my $m = sprintf("%02d", > $MONTH-1);#print "month $m"; > my $m='01'; > my $y=2011; > my $start="$y-$m-01";my $first="$y-$m-01"; > > my %dh; > $dbh = DBI->connect("dbi:mysql:ts_testing","root","dfrethbyh") or die > "Error: can connect "; > $sth=$dbh->prepare("SELECT * FROM `timesheet_times` WHERE > YEAR(start_time) =2011 AND MONTH ( start_time) BETWEEN 1 and 6 ORDER > BY start_time"); > $sth->execute() or die "Cannot execute : $DBI::errstr\n"; > while ( my $ref=$sth->fetchrow_hashref() ) > {my $s=$ref->{start_time};my $k=tosecs($s);my %h=%{$ref}; > $dh{$k}=\%h; > } > > open (F, '>/tmp/export.txt'); > > for my $t (sort keys %dh) > { > my $a=$dh{$t};my @s; > foreach my $k ( keys %$a ) > { > if (exists ($$a{$k})) > { > push @s,$$a{$k}; > } > else > { > push @s," "; > } > } > my $string = join (": ", @s); > print F "$string\n"; > > } > close F; > exit; > > sub isHoliday > { > my $r; > my $d =shift; > my $a =extractdate($d);# print "a is $a"; > foreach ( @holidays) > { > # print "foreach ".$_;print " a is $a \n"; > if ($a eq $_){ $r=1;last} > } > return $r; > > } > > |