rainabba / jquery-table2excel

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

add style on excel #110

Closed MuhammedAlmaz closed 5 years ago

MuhammedAlmaz commented 5 years ago

change this code for use style of table.

MuhammedAlmaz commented 5 years ago
                        $(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"),
                                style: $(this).attr("style"),
                                flag: $(q).find(e.settings.exclude)
                            };

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

                                } else {
                                    tempRows += "<td";
                                    if( rc.style) {
                                        tempRows +=  " style='"+rc.style+"' ";
                                    }
                                    if( rc.rows > 0) {
                                        tempRows += " rowspan=\'" + rc.rows + "\' ";
                                    }
                                    if( rc.cols > 0) {
                                        tempRows += " colspan=\'" + rc.cols + "\' ";
                                    }
                                    tempRows += "/>" + $(q).html() + "</td>";
                                }
                            }
                        });
rainabba commented 5 years ago

Thanks for contributing