<?php
require 'conexao.php';

header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=ordens_servico.xls");

$res = $mysqli->query("SELECT * FROM ordens_servico ORDER BY data_entrada DESC");

echo "OS\tSolicitante\tSetor\tTelefone\tEquipamento\tMarca\tModelo\tPatrimonio\tEntrada\tStatus\n";

while ($r = $res->fetch_assoc()) {
  echo "{$r['numero_os']}\t{$r['nome_solicitante']}\t{$r['setor']}\t{$r['telefone']}\t{$r['tipo_equipamento']}\t{$r['marca']}\t{$r['modelo']}\t{$r['patrimonio']}\t{$r['data_entrada']}\t{$r['status']}\n";
}
