|
Posted by Moot on 06/08/07 12:45
On Jun 7, 7:33 pm, "Paul" <l...@invalid.com> wrote:
> I use OpenOffice but I suppose similar formatting rules apply to MS Excel.
> For example, to format a cell for two digit numbering, the format code is:
>
> #,##0.00
>
> I can use formulas (=F$temp + 5) and there's likely a way to write
> formatting strings in the output code, I just need a little help. Any
> ideas?
>
> My code is fairly typical to export to spreadsheet:
> //get data from database
> header("Content-type: application/octet-stream");
> header("Content-Disposition: attachment; filename=\"my-data.xls\"");
> $data = "";
> $temp = 0;
> foreach($r as $row) {
> $temp++;
> $data .= $row['data1'].",".$row['some_number'].",=F$temp + 5\r\n";};
>
> echo $data;
I'm not sure OOo can do the same thing, but how I format for Excel is
pretty simple. What I do is create a new spreadsheet with some sample
data formatted to look how I want, then Save As... as XML. You can
then open the file up in any text editor to see the xml code and from
there you should be able to figure out how to format the way you
want.
In fact, this is the way I do all my excel stuff now, since it's much
easier this way. Just create a mock-up, then recreate the same thing
programmatically.
Navigation:
[Reply to this message]
|