1

I am using dataTables (http://www.datatables.net/release-datatables/media/js/jquery.dataTables.js) & tableTools (http://www.datatables.net/release-datatables/extensions/TableTools/js/dataTables.tableTools.js & http://www.datatables.net/release-datatables/extensions/TableTools/css/dataTables.tableTools.css) and displaying a table and want to print it. But am having problems with the same.

Here are my options

 $("#reportTableId").DataTable({
            "paging": false,
            "ordering": false,
            "info": false,
            "sDom": 'Tlrt',
            "iDisplayLength": 100,
            tableTools: {
                "sSwfPath": "../ed1/static/swf/copy_csv_xls_pdf.swf",
                "aButtons": [
                    {
                        "sExtends": "collection",
                        "sButtonText": "Save",
                        "aButtons": [
                            {
                                "sExtends": "xls",
                                "sTitle": $Name
                            },
                            {
                                "sExtends": "pdf",
                                "sTitle": $Name
                            }
                        ],
                        "mColumns": [0, 1, 2],
                        "sPdfOrientation": "landscape"
                    },
                    {
                        "sExtends": "print",
                        "mColumns": "visible"
                    }
                ]
            }
        });

My report html structure is in the following format

    <table id="reportTableId">
  <tr>
    <th class="tg-031e" colspan="2"></th>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
  <tr>
    <td class="tg-031e" colspan="2"></td>
  </tr>
  <tr>
    <td class="tg-031e"></td>
    <td class="tg-031e"></td>
  </tr>
</table>

css

   .tg-031ea {
        width: 15%;
    }
  1. When I try to export to Excel, I get only the 1st columns, don't get the second;
  2. In excel no cell colors are exported
  3. In PDF I get only 1 page output thought the report HTML is 13 pages. I have tried to include columns, but no success.

Any help would be much appreciated.

HTML output: HTML snapshot

PDF output: (only the heading column) pdf output

1 Answer 1

1

Hope this is not too late, from my previous experience, I have learnt that Datatables requires valud HTML table, so having a colspan in your table does not help.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, found it the hard way, but you are right, I had to remove the colspan and now its working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.