rainabba / jquery-table2excel

jQuery Plugin to export HTML tabled to Excel Spreadsheet Compatible Files
592 stars 665 forks source link

[display: none;] <- it had no effect.????? #119

Open chennanpo opened 5 years ago

chennanpo commented 5 years ago

`

100
                  <td>200</td>
                  <td>300</td>
                </tr>
                <tr>
                  <td>400</td>
                  <td>500</td>
                  <td>600</td>
                </tr>
                <tr style="display:none">
                  <td>700</td>
                  <td>800</td>
                  <td>900</td>
                </tr>`
mohamdfoad commented 4 years ago

Hi I have solved your issue by modifying the code in the table2excel.js file yu can replace infile between // comments!

        // get contents of table except for exclude
        $(e.element).each(function (i, o) {
            var tempRows = "";
            var elecontent
             $(o).find("tr").not(e.settings.exclude).each(function (i, p) {
                // console.log(o);
            if (document.getElementById("mydesiredtable").rows.item(i).style.display == "none") {

            }
            else
            {
                tempRows += "<tr>";
                $(p).find("td,th").not(e.settings.exclude).each(function (i, q) { // p did not exist, I corrected

                    var rc = {
                        rows: $(this).attr("rowspan"),
                        cols: $(this).attr("colspan"),
                        flag: $(q).find(e.settings.exclude)
                    };

                    if (rc.flag.length > 0) {
                        tempRows += "<td> </td>"; // exclude it!!
                    } else {
                        if (rc.rows & rc.cols) {
                            tempRows += "<td>" + $(q).html() + "</td>";
                        } else {
                            tempRows += "<td";
                            if (rc.rows > 0) {
                                tempRows += " rowspan=\'" + rc.rows + "\' ";
                            }
                            if (rc.cols > 0) {
                                tempRows += " colspan=\'" + rc.cols + "\' ";
                            }
                            tempRows += "/>" + $(q).html() + "</td>";
                        }
                    }
                });

                tempRows += "</tr>";
                //console.log(tempRows);
                }
            });
            // exclude img tags 
mrmuminov commented 3 years ago

exclude

there is such a parameter it’s nice to see what it’s all about