Tabletools Export Excel Pre-table content format conversion application

Source: Internet
Author: User

When we do the project, we use the DataTable plugin Tabletools

The page references are as follows:

<script src= "@Url. Content (" ~/content/media/js/tabletools.min.js ")" Type= "Text/javascript" ></script>
<link href= "@Url. Content (" ~/content/media/css/tabletools.css ")" rel= "stylesheet"/>

To export Excel formats:

It turns out that the format of the account# column is a number. The problem is, if account# 's content is 000001245678, then that column will take 00000 off, in Excel, no matter how to set the cell column format, can not be restored, then the value of this column will lose its own value solution one:

Tabletools exported Excel is opened with Notepad, all copies are copied, and then a new Excel format file can be pasted to complete this requirement.

Disadvantage: The user is God, so that users operate 3 times, the experience of poor, the next unwise solution two:

Breakthrough problem Key point: look up all kinds of data, in simple Excel, want to display 0 of the string at the beginning of all can be used (equal double quotation mark will be displayed in the content) = ""

So before I tabletools export Excel, I need to do a deal with the value of the table-specific column, look at the official Tabletools data, and work with a few lines of code to see the code implementation:

<script type= "Text/javascript" > $ (document). Ready (function () {$ ("#RepPaymentTable"). DataTable (  {"Bfilter": false, "Bsort": True, "binfo": false, "bpaginate": False, "Bstatesave": false, "sdom": "T", "Bjqueryui": true, "Aaso Rting ": []," sdom ": ' <" H "tfl>t<" F "ip> '," Otabletools ": {" SSWFPA
                      Th ":" @Url. Content ("~/content/media/swf/copy_csv_xls.swf") "," abuttons ": [{ "Sextends": "xls", "Bfooter": false, "Fncellrender": function (SV  

Alue, Icolumn, NTR, Idataindex) {if (Icolumn = = 2) {//This column is the account# corresponds to the form to be processed, the official to the Fncellrender several from the parameters do the following explanation:  1.*-The value from the cell ' s data (corresponding to this column)//2.int-the column number being read (column numbers, validated, the column numbers are starting from 0)//3.node-the TR element for the row (the bankLike)//4.int-the internal DataTables cache index for the row (based on fngetposition) (the row's internal datasheet Caching index (based on fngetposition))
                              if (svalue!= "") {return "=\" "+ svalue +" "";
                      } return svalue;
    }
                  }
                  ],
              }
          });
}); </script>

Simple logging is complete

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.