I used to think that exporting data from a Grid or able to an Excel file is very complicated, and it may be too difficult to use a class library or something.
After reading the FineUI Implementation Method for exporting Grid to Excel, it is actually very simple. It seems that it is very difficult to change one idea.
1. Aspx background code outputs Content Type informationCopy codeThe Code is as follows: Response. ClearContent ();
Response. AddHeader ("content-disposition", "attachment; filename=MyExcelFile.xls ");
Response. ContentType = "application/excel ";
Response. Write (GetGridTableHtml (Grid1 ));
Response. End (); 2. Directly output Html code
Response. Write (@"
<Table border = "1">
<Tr>
<Td> Excel </td>
<Td> By Html </td>
</Tr>
</Table> ")
This implementation is sufficient for simply exporting data to Excel.
Test method: Save the html code as an Excel file to see the effect.