Re: export data to a ms excel file using php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear all,

I found the solution for my problem.
try this core...

-----------------------------------------------------------------------------------------------------------------------

<?php
#Setting MIME Type in header
/*header("Content-Type:  application/vnd.ms-excel"); */
header("Content-Type:  application/vnd.ms-excel");
header("Expires: 0");
/*header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); */
header("Cache-Control: must-revalidate");


# Connecting to oracle server
$dbh = oci_connect ('TESTDB', 'TESTDB', '//192.168.3.197/ORCL');

# Querry for fetching the column names
$stmt = oci_parse ($dbh, "Select COLUMN_NAME from user_tab_columns where
table_name='EMPLOYEE'");

# Execution of above statement
oci_execute ($stmt);
$cnt = 1;

# Fetching column names and printing
while ($result = oci_fetch_array($stmt)) {
    echo $result['COLUMN_NAME'] . ",";
    $cnt = $cnt +1;
}
# Make a new line to write the record sets in the next line
echo "\n";

# Querry for fetching the recors sets
$stmt = oci_parse ($dbh, 'select * from employee');

# Here we execute the statement:
oci_execute ($stmt);
$cnt = 1;
/*echo '<table border="1">';*/
# Then we fetch rows in a loop until we're done
while ($result = oci_fetch_array($stmt)) {
    /*echo "gopi, gopi, gopi, gopi, gopi, gopi, gopi \n";*/
   /*echo "Employee id " . $result['EID'] . " " . $result['FNAME'] . " " .
$result['LNAME'] . $result["SALARY"] ."<br>";*/
   echo $result['EID'] . "," . $result['FNAME'] . "," . $result['LNAME'] .
"," . $result["SALARY"] ."\n";
   $cnt = $cnt +1;
}
/*echo '</table>';*/
# last we close the database handle
oci_close($dbh);
?>

-----------------------------------------------------------------------------------------------------------------------



On Thu, Oct 23, 2008 at 5:15 PM, Jay Blanchard <jblanchard@xxxxxxxxxx>wrote:

> [snip]
> Could any one explain better. I need just the grid lines for the excel
> sheet. I already tried that <table border=1> but it shows the linings
> only
> to the valued cells. But i need to show the grid as in MS Excel. I tried
> TEXT/XML
> but i get the following error
> [/snip]
>
> http://evolt.org/node/26896
>
> Part of the problem is that an empty table cell has no borders. To
> combat this you can test for a value and if it has none place a
> non-breaking space it (&nbsp;)
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux