In the end of the project, the test recently done a forum, which has an export function, found that click on the page Export button, the page table content saved as an Excel file, but found that can not save the table style, after the problem analysis to find the root cause, The following small series on my realization of the idea to share as follows:
Problem Description:
Problem Analysis Process:
The 1.table table is in class, not style. The class definition is not exported, and if you change to style, the style is exported by writing the color style directly in the style.
Style is a style that is used in HTML to indicate the attribute style, is the content in the CSS, and class is the class, declares and defines the contents of the content, export the page does not export the definition that is defined as class style.
2. You can also export a style by placing the class definition in a table
The following two scenarios are used to resolve this problem.
Treatment Scheme I:
Replace the class= "${getclass ()}" with Style= "Color:${getstyle ()};"
Add:
$ (' #export '). Click (function () {
saveasexcel ($ (' H3 '). Text (), $ (' #table '). html (). Replace (/() +/gi, ');
});
Where Excel recognizes only the table, the class definition is not saved when the Saveasexcel method is used automatically, and the class definition is saved if the manual copy is pasted into Excel.
Mainly manual and automatic copy pasting problem
Treatment Programme II:
Move the class defined in
The above content is the whole content of this article, Hope everybody likes.