rainabba / jquery-table2excel

jQuery Plugin to export HTML tabled to Excel Spreadsheet Compatible Files
593 stars 666 forks source link

How to give different css styles to excel than html table using table2excel #59

Open vasubalaga opened 7 years ago

vasubalaga commented 7 years ago

Can anyone suggest How to give different css styles to exported excel file than html table using table2excel.js file

marie15 commented 7 years ago

I have the same issue. I tried t use inline css but not working.

MuhammedAlmaz commented 5 years ago

@marie15 , @vasubalaga

Change this code block

$(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>";
                                }
                            }
                        });