Jump to content

Exporting to excel file


dc_jt

Recommended Posts

Hi

I have the following code which queries my database and shows results in excel.

However, when i open excel to view it the name, email, address etc start on row 2 instead of 1 for some reason.

Also, there is a little square at the end of each row.

Any ideas how to get rid of this?

Here is the code

[quote]<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/config.inc.php');
require_once(LOCAL_CLASSES.'/Tables/RCLTblReaders.class.php');

header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=UserMemories".str_replace(' ','', $sUserMemories)."_".$sCurrentDate.".csv");
    header("Pragma: no-cache");
    header("Expires: 0");

    $oTblReaders = new RCLTblReaders();
    $rReaders = $oTblReaders->GetDataP();
   
print "Name, Email, Address, Town, City, Postcode, Country";
    while ($oReaders = mysql_fetch_object($rReaders))
{?>
<?php

print "$oReaders->name, $oReaders->email, $oReaders->address, $oReaders->town, $oReaders->city, $oReaders->postcode, $oReaders->country";

}?>[/quote]

Thanks
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.