<?php
include("prueba.php");
if($_GET['empresa']=='Envia'){
include("conexion2.php");
}else{
include("conexion3.php");
}

session_destroy();
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Rs = 5000;// este numero es el numero de resultados que quieren que se vean por pagina pueden poner algo asi: $maxRows_Rs = 6; para ver paginas con 6 resultados
$pageNum_Rs = 0;
if (isset($_GET['pageNum_Rs'])) {
  $pageNum_Rs = $_GET['pageNum_Rs'];
}
$startRow_Rs = $pageNum_Rs * $maxRows_Rs;
mysql_select_db($db, $conexion);
 $est=1;

// Excel begin of file header
function xlsBOF()
{
echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
return;
}
// Excel end of file footer
function xlsEOF()
{ 
echo pack("ss", 0x0A, 0x00);
return;
}
// Function to write a Number (double) into Row, Col
function xlsWriteNumber($Row, $Col, $Value)
{
echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
echo pack("d", $Value);
return;
}
// Function to write a label (text) into Row, Col
function xlsWriteLabel($Row, $Col, $Value )
{
$L = strlen($Value);
echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
echo $Value;
return;
}
// ----- end of function library -----
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-type: application/x-msexcel");
header ("Content-Disposition: attachment; filename=generaxls.xls" );
header ("Content-Description: PHP/INTERBASE Generated Data" );
xlsBOF(); // begin Excel stream
$est=$_GET['estado'];
$lot=$_GET['lote'];
$rst="Select * from servicio_cliente where est='$est' and lote='$lot'";
$query_limit_Rs = sprintf("%s LIMIT %d, %d", $rst, $startRow_Rs, $maxRows_Rs);
$Rs = mysql_query($query_limit_Rs, $conexion) or die(mysql_error());
$row_Rs = mysql_fetch_assoc($Rs);
xlsWriteLabel(0,0,"GUIA"); // write a label in A1, use for dates too
//xlsWriteLabel(0,1,"NUMERO CUENTA");
xlsWriteLabel(0,2,$_GET['empresa']);
xlsWriteLabel(0,1,"PATH");
$i=1;
do {
$ced=$row_Rs['guia'];
$loc=$row_Rs['ruta'];
xlsWriteNumber($i,0,$ced); // write a label in A1, use for dates too
//xlsWriteLabel($i,1,$row_Rs['num_cta']);
//xlsWriteLabel($i,2,$row_Rs['nom_cta']);
xlsWriteLabel($i,1,$loc);
$i=$i+1;
} while ($row_Rs = mysql_fetch_assoc($Rs));
 
 // write a number B1
xlsEOF(); // close the stream


?>
