将PHP不同的动态表水平导出到EXCEL / SPREADSHEET

时间:2017-11-15 08:31:06

标签: javascript php

我正在使用https://github.com/rainabba/jquery-table2excel

找到的 php2excel

这是输出图像

enter image description

这就是我想要的输出

enter image description here

<script type="text/javascript" src="dist/jquery.table2excel.min.js"></script>

          <script>
                          function printReports() {   
                              $(".center").table2excel({
                                exclude: ".noExl",
                                name: "Excel Document Name",
                                filename: "Term_Grades" + new Date().toISOString().replace(/[\-\:\.]/g, ""),
                                fileext: ".xlsx",
                                exclude_img: true,
                                exclude_links: true,
                                exclude_inputs: true
                              });
                            };
                          </script>

下载                               

                              <table border='0' class="table" style="border-color: white;float:left; width:18%">
                                <thead >
                                  <!-- <th>#</th> -->
                                  <th style= "background-color: #008066; color: white; height:60px; width: 28px; font-size:12px">No</th>
                                  <th style= "background-color: #008066; color: white; height:60px; width: 115px; font-size:12px">Lastname</th>   
                                  <th style= "background-color: #008066; color: white; height:60px; width: 42px; font-size:12px">SN</th>
                                  <th style= "background-color: #008066; color: white; height:60px; width: 100px; font-size:12px">COY</th>  
                                </thead>
                                <tbody>

                                  <tr>
                                    <td>1</td>
                                    <td>2</td>
                                    <td>3</td>
                                    <td>4</td>
                                  <tr>
                                  <tr>
                                    <td>5</td>
                                    <td>6</td>
                                    <td>7</td>
                                    <td>8</td>
                                  <tr>



                                </tbody>
                              </table>



                              <table border='0' class="table" style="border-color: white;float:left; width:18%">
                                <thead >
                                  <!-- <th>#</th> -->
                                  <th style= "background-color: #008066; color: white; height:60px; width: 28px; font-size:12px">Another No</th>
                                  <th style= "background-color: #008066; color: white; height:60px; width: 115px; font-size:12px">Another Lastname</th>   
                                  <th style= "background-color: #008066; color: white; height:60px; width: 42px; font-size:12px">Another SN</th>
                                  <th style= "background-color: #008066; color: white; height:60px; width: 100px; font-size:12px">Another COY</th>  
                                </thead>
                                <tbody>

                                  <tr>
                                    <td>Another 1</td>
                                    <td>Another 2</td>
                                    <td>Another 3</td>
                                    <td>Another 4</td>
                                  <tr>
                                  <tr>
                                    <td>Another 5</td>
                                    <td>Another 6</td>
                                    <td>Another 7</td>
                                    <td>Another 8</td>
                                  <tr>



                                </tbody>
                              </table>

                              <table border='0' class="table" style="border-color: white;float:left; width:18%">
                                <thead >
                                  <!-- <th>#</th> -->
                                  <th style= "background-color: #008066; color: white; height:60px; width: 28px; font-size:12px">Some No</th>
                                  <th style= "background-color: #008066; color: white; height:60px; width: 115px; font-size:12px">Some Lastname</th>   
                                  <th style= "background-color: #008066; color: white; height:60px; width: 42px; font-size:12px">Some SN</th>
                                  <th style= "background-color: #008066; color: white; height:60px; width: 100px; font-size:12px">Some COY</th>  
                                </thead>
                                <tbody>

                                  <tr>
                                    <td>Some 1</td>
                                    <td>Some 2</td>
                                    <td>Some 3</td>
                                    <td>Some 4</td>
                                  <tr>

                                  <tr>
                                    <td>Some 5</td>
                                    <td>Some 6</td>
                                    <td>Some 7</td>
                                    <td>Some 8</td>
                                  <tr>


                                </tbody>
                              </table>

                          </div>

导出时excel文件的输出是2个表位于底部而不是彼此并排。由于其他情况,我不能将3个表加入1。上面的代码只是一个虚拟表

1 个答案:

答案 0 :(得分:0)

如何使3个html表并排显示在excel文件中。目前的输出是3个表在彼此的末尾。代码在上面,输出显示在图片中