How to generate a report in excel with multiple fields

0

I want to generate a report with excel where the user may or may not enter one or more fields

esta es la estrucutura de mi base
CREATE TABLE 'tablacompleta' (
  'supertoken_id' bigint(20) NOT NULL,
  'num_bug' bigint(15) DEFAULT NULL,
  'n_caja' int(11) DEFAULT NULL,
  'estatus_bboo' mediumtext,
  'fecha_sistema' timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  'motivo' varchar(45) DEFAULT NULL,
  'operador' varchar(45) DEFAULT NULL,
  'tipo_token' varchar(45) DEFAULT NULL,
  'estatus_token' varchar(45) DEFAULT NULL,
  'sucursal' int(11) DEFAULT NULL,
  'region' varchar(45) DEFAULT NULL,
  PRIMARY KEY ('supertoken_id')
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

The screen on the left is where I'm going to get the data and generate a table with the results

<html lang="es">
	<head>
		<link rel="stylesheet" type="text/css" href="DataTables-1.10.16/css/jquery.dataTables.css"/>
		<link rel="stylesheet" type="text/css" href="Buttons-1.5.1/css/buttons.dataTables.css"/>
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/bootstrap-theme.css" rel="stylesheet">
		<link href="css/style.css" rel="stylesheet">
		<link href="jqueryui/jquery-ui.css" rel="stylesheet">
		<link href="jqueryui/style.css" rel="stylesheet">
 
<script type="text/javascript" src="jQuery-3.2.1/jquery-3.2.1.js"></script>
<script type="text/javascript" src="jQuery-1.12.3/jquery-1.12.3.js"></script>
<script type="text/javascript" src="DataTables-1.10.16/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="Buttons-1.5.1/js/dataTables.buttons.js"></script>
<script src="jqueryui/jquery.js"></script>
<script src="jqueryui/jquery-ui.js"></script>

<script>
$(function () {
$("#datepicker").datepicker();
});

function numeros(evt)
        {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;
 
         return true;
        }

</script>

<title>////Registro de Tokens Incompletos***</title>
			<div id="centro">
				<br /> <br /> <br /> <br /> 

		 		<h1>Registrar Tokens Incompletos</h1>
		 	</div>
	</head>
	
	<body>
		<div class="container">
			<div class="row">
				
				 <center>
				
				
				<br /> <br/>
				<br /> <br/>	
        		</center>
			</div>
			
			<form class="form-horizontal" method="POST" action="guardar.php" enctype="multipart/form-data" autocomplete="on">
				<div class="form-group">
					<label for="estado_civil" class="col-sm-2 control-label">Nombre del operador</label>
					<div class="col-sm-8">
						<select class="form-control" id="motivo" name="motivo" required>
							<option value="Abigail">Abigail</option>
							
							<option value="jose">jose</option>
						</select>
					</div>
				</div>

				<input type="hidden" class="col-sm-8 control-label" name="fecha_sistema" readonly="readonly" echo "Error al cargar archivo" value="<?php date_default_timezone_set('America/Mexico_City'); echo date('Y-m-d');?>"><br/>
        		
				<div class="form-group">
					<label for="telefono" class="col-sm-2 control-label">Num de Token</label>
					<div class="col-sm-6">
						<input type="text" class="form-control" id="supertoken" name="supertoken_id" onkeypress="return numeros(event)" placeholder="Maximo 9 digitos" maxlength="9" required>
					</div>
				</div>

				<div class="form-group">
					<label for="telefono" class="col-sm-2 control-label">Estatus de Token</label>
					<div class="col-sm-6">
						<input type="text" value="111111" class="form-control" id="estatus_token" name="estatus_token" onkeypress="return numeros(event)" placeholder="Maximo 9 digitos" maxlength="9" required>
					</div>
				</div>


				<div class="form-group">
					<label for="telefono" class="col-sm-2 control-label">Num de Buc</label>
					<div class="col-sm-6">
						<input type="tel" class="form-control" id="num_bug" name="num_bug" onkeypress="return numeros(event)" placeholder="Maximo 8 digitos" maxlength="8" required>
					</div>
				</div>
				<div class="form-group">
					<label for="telefono" class="col-sm-2 control-label">Num de Caja</label>
					<div class="col-sm-6">
						<input type="num" class="form-control" id="n_caja" name="n_caja" onkeypress="return numeros(event)" placeholder="Numero de caja" maxlength="9" required>
					</div>
				</div>

				<div class="form-group">
					<label for="estado_civil" class="col-sm-2 control-label">Tipo De Token</label>
					<div class="col-sm-6">
						<select class="form-control" id="tipo_token" name="tipo_token" required>
						<option value="Supertoken">Super token</option>
							<option value="Supernet">Super net</option>
							<option value="Enlace">Enlace</option>
						</select>
					</div>
				</div>

				
				

				<div class="form-group">
					<label for="estado_civil" class="col-sm-2 control-label">Motivo de rechazo</label>
					<div class="col-sm-8">
						<select class="form-control" id="motivo" name="motivo" required>
							<option value="RECHAZO POR FALTA DE NOMBRE Y/O CLAVE DE FIRMA DE EJECUTIVO EN Vo.Bo. Y COTEJO">RECHAZO POR FALTA DE NOMBRE Y/O CLAVE DE FIRMA DE EJECUTIVO EN Vo.Bo. Y COTEJO</option>
							
							<option value="otro">OTRO</option>
						</select>
					</div>
				</div>
				
				
				
				
				

				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						<a href="registrosincompletos.php" class="btn btn-default">Regresar</a>
						<button type="submit" class="btn btn-primary">Guardar</button>
					</div>
				</div>
			</form>
		</div>
	</body>
</html>
<?php

error_reporting (E_ALL); set_time_limit (0); ini_set ('memory_limit', '1024M'); ini_set ('include_path', ini_get ('include_path'). '; ClassesExcel /'); include ("includes / ClassesExcel / PHPExcel.php"); include ('includes / ClassesExcel / PHPExcel / Writer / Excel2007.php'); require ('connection_bd / connection.php');

if (PHP_SAPI == 'cli')     die ('');

/ ** Include PHPExcel * / require_once dirname ( FILE ). '/includes/ClassesExcel/PHPExcel.php';     // $ query = $ _POST ['query'];

Connect ();

// $ query="SELECT supertoken_id, n_box, reason, operator, date_cap, type_token, num_bug, system_date FROM table_complete";

// $ j = 1; for ($ j = 1; $ j < = 2; $ j ++) {

$ query="SELECT count (*) FROM link where date BETWEEN '2017-04-01' AND '2017-04-30.23: 00: 00' and idZona = $ j;";     $ result = Execute Queries ($ query);

        $pag=0;
        $objPHPExcel = new PHPExcel();
        $fechaBD = date('Y-m-d');
        $tipo="Enlace";
        $i=$j+1;

while (@ $ data = mysql_fetch_array ($ result)) {
        ////////HEADER/////////        $ dat = $ data [0];

         $objPHPExcel->setActiveSheetIndex($pag)
    ->setCellValue('A1', "Cantidad")
    ->setCellValueExplicit('B1',"Zona")
     ->setCellValueExplicit('C1',"Region")
     ->setCellValueExplicit('D1',"Tipo")


                    ->setCellValue('A'.$i, $dat)
                    ->setCellValueExplicit('D'.$i, $tipo);

} // end while

}

$ objPHPExcel-> getActiveSheet () -> setTitle ('Download'); $ objPHPExcel-> setActiveSheetIndex (0); $ fecham = date ('d-m-Y'); $ filename = 'Download'. $ fecham;

// Redirect output to a client's web browser (Excel2007) header ('Content-Type: application / vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header ('Content-Disposition: attachment; filename="'. $ filename. '. xlsx"'); header ('Cache-Control: max-age = 0'); header ('Cache-Control: max-age = 1');

// If you're serving to IE over SSL, then the following may be needed header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header ('Last-Modified:' .gmdate ('D, d M Y H: i: s'). 'GMT'); // always modified header ('Cache-Control: cache, must-revalidate'); // HTTP / 1.1 header ('Pragma: public'); // HTTP / 1.0

$ objWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'Excel2007');  ob_end_clean ();

$ objWriter-> save ('php: // output'); // $ objWriter-> save ('C: / Downloads / Portfolio /'. $ filename) '.xlsx');

exit; ? >

    
asked by sanlegas 24.03.2018 в 02:31
source

0 answers