Ya lo resolvi yo mismo usando una clase PHPExcel y asignandole ciertos parametros al formato aqui el codigo para quien lo necesite:
Código PHP:
<?php
require_once('../Connections/ternerita.php');
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset3") == false &&
stristr($param, "totalRows_Recordset3") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset3 = "&" . htmlentities(implode("&", $newParams));
}
}
$prefijo_sql = " SELECT * ";
require_once('../Connections/ternerita.php');
$condiciones = array();
if (!empty($_POST['nombre'])) {
$condiciones[] = "nombre";
}
if (!empty($_POST['celular'])) {
$condiciones[] = "celular";
}
if (!empty($_POST['PIN'])) {
$condiciones[] = "PIN";
}
if (!empty($_POST['telefono'])) {
$condiciones[] = "telefono";
}
if (!empty($_POST['direccion'])) {
$condiciones[] = "direccion";
}
if (!empty($_POST['correo'])) {
$condiciones[] = "correo";
}
if (!empty($_POST['sexo'])) {
$condiciones[] = "sexo";
}
if (!empty($_POST['profesion'])) {
$condiciones[] = "profesion";
}
if (count($condiciones) > 0) {
$prefijo_sql = " SELECT " . implode( ",", $condiciones );
} else {
$prefijo_sql = " SELECT * ";
}
mysql_select_db($database_ternerita, $ternerita);
$query_Recordset1 = $prefijo_sql." FROM suscriptor ORDER BY id_ususario ASC ";
$Recordset1 = mysql_query($query_Recordset1, $ternerita) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$filename = 'reporte_excel.xls';
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header("Content-Disposition: attachment;filename={$filename}");
header('Content-Transfer-Encoding: binary');
error_reporting(E_ALL);
set_include_path(get_include_path() . PATH_SEPARATOR . '../Clases/Classes/');
include 'PHPExcel.php';
include 'PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Mi Ternerita");
$objPHPExcel->getProperties()->setLastModifiedBy("Mi Ternerita");
$objPHPExcel->getProperties()->setTitle("Mi Ternerita");
$objPHPExcel->getProperties()->setSubject("Listado de Suscriptores");
$objPHPExcel->getProperties()->setDescription("Listado de Suscriptores");
$objPHPExcel->getProperties()->setKeywords("office 2007 suscriptores listado openxml php");
$objPHPExcel->getProperties()->setCategory("file office 2007 suscriptores listado");
$objPHPExcel->setActiveSheetIndex(0);
if (!empty($_POST['nombre'])) { $objPHPExcel->getActiveSheet()->setCellValue('A1','NOMBRE'); }
if (!empty($_POST['celular'])) { $objPHPExcel->getActiveSheet()->setCellValue('B1','CELULAR'); }
if (!empty($_POST['PIN'])) { $objPHPExcel->getActiveSheet()->setCellValue('C1','PIN'); }
if (!empty($_POST['telefono'])) { $objPHPExcel->getActiveSheet()->setCellValue('D1','TELEFONO'); }
if (!empty($_POST['direccion'])) { $objPHPExcel->getActiveSheet()->setCellValue('E1','DIRECCION'); }
if (!empty($_POST['correo'])) { $objPHPExcel->getActiveSheet()->setCellValue('F1','CORREO'); }
if (!empty($_POST['sexo'])) { $objPHPExcel->getActiveSheet()->setCellValue('G1','SEXO'); }
if (!empty($_POST['profesion'])) { $objPHPExcel->getActiveSheet()->setCellValue('H1','PROFESION'); }
$xi = 2;
do {
if (!empty($_POST['nombre'])) { $objPHPExcel->getActiveSheet()->setCellValue('A'.$xi, $row_Recordset1['nombre']); }
if (!empty($_POST['celular'])) {
$objPHPExcel->getActiveSheet()->getCell('B'.$xi)->setValue($row_Recordset1['celular']);
$objPHPExcel->getActiveSheet()->getStyle('B'.$xi)->getNumberFormat()->setFormatCode('00000000000');
}
if (!empty($_POST['PIN'])) { $objPHPExcel->getActiveSheet()->setCellValue('C'.$xi, $row_Recordset1['PIN']); }
if (!empty($_POST['telefono'])) { $objPHPExcel->getActiveSheet()->setCellValue('D'.$xi, $row_Recordset1['telefono']); }
if (!empty($_POST['direccion'])) { $objPHPExcel->getActiveSheet()->setCellValue('E'.$xi, $row_Recordset1['direccion']); }
if (!empty($_POST['correo'])) { $objPHPExcel->getActiveSheet()->setCellValue('F'.$xi, $row_Recordset1['correo']); }
if (!empty($_POST['sexo'])) { $objPHPExcel->getActiveSheet()->setCellValue('G'.$xi, $row_Recordset1['sexo']); }
if (!empty($_POST['profesion'])) { $objPHPExcel->getActiveSheet()->setCellValue('H'.$xi, $row_Recordset1['profesion']); }
$xi++;
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
mysql_free_result($Recordset1);
?>