jquery-table2excel icon indicating copy to clipboard operation
jquery-table2excel copied to clipboard

No border in excel file

Open kingzez opened this issue 8 years ago • 2 comments

the export excel file's content has no border

kingzez avatar Jun 19 '17 05:06 kingzez

Okey! Search; console.log(tempRows);

Add before tempRows = $(o).html();

border and other style items are working!

Enjoy

atalayxx avatar Feb 28 '18 14:02 atalayxx

$(p).find("td,th").not(e.settings.exclude).each(function (i,q) {
	additionalStyles = "";
	if(e.settings.preserveColors){
		compStyle = getComputedStyle(q);
		additionalStyles += (compStyle && compStyle.backgroundColor ? "background-color: " + compStyle.backgroundColor + ";" : "");
		additionalStyles += (compStyle && compStyle.color ? "color: " + compStyle.color + ";" : "");
		//I added this line below, and it shows border in Excel. 1px border in Excel is too thick so I replaced it with 0.3pt.
		additionalStyles+=(compStyle&&compStyle.border?"border: "+compStyle.border.replace("1px",".3pt")+";":"");  
	}
	var rc = {
		rows: $(this).attr("rowspan"),
		cols: $(this).attr("colspan"),
		flag: $(q).find(e.settings.exclude)
	};
	if( rc.flag.length > 0 ) {
		tempRows += "<td> </td>";
	} else {
		tempRows += "<td";
		if( rc.rows > 0) {
			tempRows += " rowspan='" + rc.rows + "' ";
		}
		if( rc.cols > 0) {
			tempRows += " colspan='" + rc.cols + "' ";
		}
		if(additionalStyles){
			tempRows += " style='" + additionalStyles + "'";
		}
		tempRows += ">" + $(q).html() + "</td>";
	}
});

vegetas940 avatar Nov 01 '21 07:11 vegetas940