Loading ...
Sorry, an error occurred while loading the content.

to export data to an Excel sheet help needed..

Expand Messages
  • raji_ska
    Hello i am new to this php, and i need someone s help to extract data from different tables combining to an EXcel sheet..in a formatted way..Can u people help
    Message 1 of 5 , Feb 3, 2007
    • 0 Attachment
      Hello i am new to this php, and i need someone's help to extract data
      from different tables combining to an EXcel sheet..in a formatted
      way..Can u people help me out? i could the simple exraction,but
      I need to combine columns in Excel, leave some cells blank..like that
      formatting also required in excel sheet using php according to the
      values from different tables...Is it possible to format an Excel sheet
      using php? & when taking data's from different queries, it should get
      in a same excel sheet & also not to be overwritten..
    • raji_ska
      Hello i am new to this php, and i need someone s help to extract data from different tables combining to an EXcel sheet..in a formatted way..Can u people help
      Message 2 of 5 , Feb 3, 2007
      • 0 Attachment
        Hello i am new to this php, and i need someone's help to extract data
        from different tables combining to an EXcel sheet..in a formatted
        way..Can u people help me out? i could the simple exraction,but
        I need to combine columns in Excel, leave some cells blank..like that
        formatting also required in excel sheet using php according to the
        values from different tables...Is it possible to format an Excel sheet
        using php? & when taking data's from different queries, it should get
        in a same excel sheet & also not to be overwritten..
      • Rajamurugan
        HI use this code i provided .but i made it to fetch from only one table itself. But You can modify it as per your knowledge Thank U Ever Urs Rajamurugan Code
        Message 3 of 5 , Feb 8, 2007
        • 0 Attachment
          HI

          use this code i provided .but i made it to fetch from only one table
          itself.

          But You can modify it as per your knowledge

          Thank U

          Ever Urs

          Rajamurugan


          Code Start;//////////////////////

          <?
          ob_start();
          ?>
          <?
          mysql_connect("localhost","root","");
          mysql_select_db("raja");
          require_once("Spreadsheet/Excel/Writer.php");
          $s="select * from members order by id";
          $s1=mysql_query($s);
          $count = mysql_num_fields($s1);
          for ($i = 0; $i < $count; $i++)
          {
          $header .= mysql_field_name($s1, $i)."\t";
          }
          header("Content-type: application/octet-stream");
          header("Content-Disposition: attachment; filename=data.xls");
          header("Pragma: no-cache");
          header("Expires: 0");
          echo $header;
          while($row=mysql_fetch_row($s1))
          {
          $line='';

          foreach($row as $value)
          {

          if($value=='')
          {
          $value="\t";
          }
          else
          {
          $value=str_replace('"','""',$value);
          $value='"'.$value.'"'."\t";
          }
          $line.=$value;
          }
          $data=trim($line);
          $data=str_replace('\r','""',$data);
          echo "\n".$data;
          }

          //$n=mysql_num_rows($s1);
          //$s2=mysql_fetch_array($s1);
          /*print_r($s2);
          $s3=array_keys($s2);
          $date=date('d'.'m'.'y');
          mkdir($date,777);
          //$fp=fopen($date.'/data.xls',"a+");
          $xls=new Spreadsheet_Excel_Writer($date.'/data.xls');
          $sheet=$xls->addWorksheet('data');
          $a=1;
          for($i=0;$i<count($s3);$i++)
          {
          $s4=$s3[$a].' ';
          $sheet->write($s4,0,$s4);
          $a+=2;
          }
          $xls->close();
          for($i=0;$i<$n;$i++)
          {
          $name=mysql_result($s1,$i,'usrnm');

          }*/
          ?>

          //END



          --- In phpKeralaUg@yahoogroups.com, "raji_ska" <raji_ska@...> wrote:
          >
          > Hello i am new to this php, and i need someone's help to extract data
          > from different tables combining to an EXcel sheet..in a formatted
          > way..Can u people help me out? i could the simple exraction,but
          > I need to combine columns in Excel, leave some cells blank..like that
          > formatting also required in excel sheet using php according to the
          > values from different tables...Is it possible to format an Excel sheet
          > using php? & when taking data's from different queries, it should get
          > in a same excel sheet & also not to be overwritten..
          >
        • Aji Issac
          try the pear classes ... -- http://www.idealwebtools.com/blog/ - My blog
          Message 4 of 5 , Feb 9, 2007
          • 0 Attachment
            try the pear classes

            On 2/9/07, Rajamurugan <raja_671@...> wrote:

            HI

            use this code i provided .but i made it to fetch from only one table
            itself.

            But You can modify it as per your knowledge

            Thank U

            Ever Urs

            Rajamurugan

            Code Start;//////////////////////

            <?
            ob_start();
            ?>
            <?
            mysql_connect("localhost","root","");
            mysql_select_db("raja");
            require_once("Spreadsheet/Excel/Writer.php");
            $s="select * from members order by id";
            $s1=mysql_query($s);
            $count = mysql_num_fields($s1);
            for ($i = 0; $i < $count; $i++)
            {
            $header .= mysql_field_name($s1, $i)."\t";
            }
            header("Content-type: application/octet-stream");
            header("Content-Disposition: attachment; filename=data.xls");
            header("Pragma: no-cache");
            header("Expires: 0");
            echo $header;
            while($row=mysql_fetch_row($s1))
            {
            $line='';

            foreach($row as $value)
            {

            if($value=='')
            {
            $value="\t";
            }
            else
            {
            $value=str_replace('"','""',$value);
            $value='"'.$value.'"'."\t";
            }
            $line.=$value;
            }
            $data=trim($line);
            $data=str_replace('\r','""',$data);
            echo "\n".$data;
            }

            //$n=mysql_num_rows($s1);
            //$s2=mysql_fetch_array($s1);
            /*print_r($s2);
            $s3=array_keys($s2);
            $date=date('d'.'m'.'y');
            mkdir($date,777);
            //$fp=fopen($date.'/data.xls',"a+");
            $xls=new Spreadsheet_Excel_Writer($date.'/data.xls');
            $sheet=$xls->addWorksheet('data');
            $a=1;
            for($i=0;$i<count($s3);$i++)
            {
            $s4=$s3[$a].' ';
            $sheet->write($s4,0,$s4);
            $a+=2;
            }
            $xls->close();
            for($i=0;$i<$n;$i++)
            {
            $name=mysql_result($s1,$i,'usrnm');

            }*/
            ?>

            //END

            --- In phpKeralaUg@yahoogroups.com, "raji_ska" <raji_ska@...> wrote:
            >
            > Hello i am new to this php, and i need someone's help to extract data
            > from different tables combining to an EXcel sheet..in a formatted
            > way..Can u people help me out? i could the simple exraction,but
            > I need to combine columns in Excel, leave some cells blank..like that
            > formatting also required in excel sheet using php according to the
            > values from different tables...Is it possible to format an Excel sheet
            > using php? & when taking data's from different queries, it should get
            > in a same excel sheet & also not to be overwritten..
            >




            --
            http://www.idealwebtools.com/blog/ - My blog
          • raji skariah
            hai all, thanks to everybody who helped me out of the extraction problem __,_._tthathanks ,___ With Love & Prayers, Raji Pramod ... Get your own web address.
            Message 5 of 5 , Feb 13, 2007
            • 0 Attachment
              hai all,
                     thanks to everybody who helped me out of the extraction problem

              __,_._tthathanks ,___



              With Love & Prayers,
                                Raji Pramod


              Get your own web address.
              Have a HUGE year through Yahoo! Small Business.

            Your message has been successfully submitted and would be delivered to recipients shortly.