Customize excel report generated with html and jquery

0

I am trying to export a common html table to Excel using Jquery. My script already prints the table, what I need is to personalize the names that appear in the headers as well as sizes of the columns, colors, etc.

This is the image of my report, you can see how the headers are a complete mess.

There is an example that you can provide, Thanks and regards.

    
asked by Diego Silva 13.10.2016 в 22:26
source

1 answer

0

I use Dompdf to generate my excel, you must download the library at the following link Click and this is the way to generate the excel with data from your PHP. The design, width colors of the columns are generated from your HTML.

    <?php
    header("Content-type: application/vnd.ms-excel");
    header("Content-Disposition: attachment; filename=tuexcel.xls");
    include("../php/conexion.php");
    $post=$_POST["post"];
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>STu Titulo</title>
    </head>
    <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
    <td colspan="3">
    <p style="margin:0px;font-size:20px" align="center"><b>Titulo<b></p>
    <p align="center" style="margin:0px;font-size:16px" ><i>SubTitulo</i></p>
    </td>
    </tr>
    <tr align="center">
    <td><p style="margin:0px;font-size:12px" > direccion</p></td>
    <td><p style="margin:0px;font-size:12px" > Telefono </p></td>
    <td><p style="margin:0px;font-size:12px" > Ciudad </p></td>
    </tr>
    </table>
    <br>
    <table width="100%" border="1" cellspacing="0" cellpadding="0" align="center">
      <tr style="font-size: 12px;" align="center" >
    <td align="right">Semestre    :</td>
    <td align="left"><?php echo $semestry; ?></td>
    <td align="right">Unidad de Aprendizaje    :</td>
    <td align="left"><?php echo $ua; ?> </td>
    </tr>
        <tr style="font-size: 12px;" align="center" >
            <td colspan="2"></td>
            <td align="right">Algo:</td>
            <td align="left"><?php echo $ut;?></td>
        </tr>
    </table>
    <br>
    <br>
    <br>
    </body>
    </html>

If the answer has been useful, do not forget to vote.

    
answered by 13.10.2016 / 22:40
source