| The code is as follows: |
Copy code |
Response. setContentType ("application/vnd. ms-Excel; charset = gb2312 "); Response. setHeader ("Content-disposition", "attachment?filename=excelfile name .xls "); |
However, we often change the long data such as ID cards to scientific notation for display.
Internet Explorer users can export a table to an Excel file if an html page has a table. However, they often change the long data such as ID card numbers to scientific notation for display. It is a headache.
It can be solved by adding a single quotation mark, but here I will test that the display and export results both have single quotation marks. Poor results.
It is better for colleagues to find a solution.
Add a css section to the html page.
Then apply the style in the problematic field.
Test passed. Magic
| The code is as follows: |
Copy code |
<Style type = "text/css"> <! -- Td { Background-color: # FFFFFF; } . Txt {Padding-top: 1px; Padding-right: 1px; Padding-left: 1px; Mso-ignore: padding; Color: black; Font-size: 11.0pt; Font-weight: 400; Font-style: normal; Text-decoration: none; Font-family:; Mso-generic-font-family: auto; Mso-font-charset: 134; Mso-number-format :"@"; Text-align: general; Vertical-align: middle; Mso-background-source: auto; Mso-pattern: auto; White-space: nowrap ;} --> </Style> |
It turns out that css still has this effect. Put the above code in the html page to be imported, and these solutions are solved.