EXPORTAR DADOS DE UMA CONSULTA EM XLS
Fala moçada boa tarde,
to com um probleminha aqui..
No caso o codigo abaixo ele imprimi toda a consulta e eu quero qe seja exportado apenas os dados em tela,como por exemplo apos uma pesquisa por uma determinada matricula.
<?
include("../../conecta.php");
require_once("include/mssql.php");
include_once("funcoes.php");
// Definimos o nome do arquivo que será exportado
$arquivo = 'relatorio_equipe.xls';
// Configurações header para forçar o download
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=\"{$arquivo}\"" );
header ("Content-Description: PHP Generated Data" );
$matricula = $_POST['matricula'];
$query = "SELECT Us_Usuario ,
No_Usuario ,
Ds_Funcao ,
Ds_Setor ,
St_Usuario ,
Dt_Admissao_Usuario ,
No_Empresa,
ds_tecnico_residente
FROM cnsEmpregados order by No_Usuario ASC ";
$resultado = mssql_query ($query);
echo "$query";
echo $matricula;
$html = '';
$html .= '<table border=1>';
$html .= '<tr>';
$html .= '<td><b>Matrícula</b></td>';
$html .= '<td><b>Nome</b></td>';
$html .= '<td><b>Cargo/Função</b></td>';
$html .= '<td><b>Coordenação</b></td>';
$html .= '<td><b>Situação</b></td>';
$html .= '<td><b>Data de Admissão</b></td>';
$html .= '<td><b>Nome da Empresa</b></td>';
$html .= '</tr>';
while($campo = mssql_fetch_array ($resultado)){
$matricula = $campo['Us_Usuario'];
$nome = $campo['No_Usuario'];
$funcao = $campo['Ds_Funcao'];
$setor = $campo['Ds_Setor'];
$situacao = $campo['St_Usuario'];
$dt_admissao = date("d/m/Y",strtotime($campo["Dt_Admissao_Usuario"]));
$nome_empresa = $campo ['No_Empresa'];
$html .= '<tr>';
$html .= '<td>' . $matricula . '</td>';
$html .= '<td>' . $nome . '</td>';
$html .= '<td>' . $funcao . '</td>';
$html .= '<td>' . $setor . '</td>';
$html .= '<td>' . $situacao . '</td>';
$html .= '<td>' . $dt_admissao . '</td>';
$html .= '<td>' . $nome_empresa . '</td>';
$html .= '</tr>';
}
$html .= '</table>';
// Envia o conteúdo do arquivo
echo $html;
exit;
?>
sera que alguem poderia ajudar?
Desde já agradeço.Discussão (2)
Carregando comentários...