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