Save the content and style of the table on the page into an excel file, tableexcel

Source: Internet
Author: User

Save the content and style of the table on the page into an excel file, tableexcel

After the project is completed, test a recently created forum with an export function. After you click Export on the webpage, save the table content on the page as an excel file, however, the table style cannot be saved. After analyzing the problem, find the root cause. The following section will share my Implementation ideas with you as follows:

Problem description:

Problem analysis process:

1. Use a class instead of a style in a table. The class definition is not exported during export. If you change to style, you can write the Color style directly in the style to export the style.

Style is a style. This is used in HTML to indicate the attribute style. It is the content in css, while class is the content in class, declaration and definition, the style defined by class is not exported when the page is exported.

2. Place the class definition in the table and export the style.

The following two solutions are provided to solve this problem.

Solution 1:

Change class = "$ {getClass ()}" to style = "color :$ {getStyle ()};"

Supplement:

 $('#export').click(function () { saveAsExcel($('h3').text(), $('#table').html().replace(/( )+/gi,'')); });

Excel only recognizes tables. When the saveAsExcel method is used for automatic saving, the class definition cannot be saved. If you copy and paste it to excel manually, the class definition can be saved.
It is mainly about manual and automatic copy and paste.

Solution 2:

Move the class defined in

The above content is all the content of this article. I hope you will like it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.