During this period, you need to use C# to make a page and export the data queried in the grid to Excel. I have found a lot of C# exporting Excel code online, but it has not been available after trying it. Many codes are for .net 2.0 or 3.0, but my program is developed using .net 1.0, which makes many functions unusable. After that, I changed my mind and looked for "Methods of Exporting Excel by UltraWebGrid", and found a batch of widely circulated texts in CSDN, but the results of my human flesh test still cannot be used. Just when I was almost desperate, I discovered that UltraWebGrid comes with controls that export Excel. It is also very simple to use, just register the front-end and call it in the background. Here is a simple example.
PS: UltraWebGrid has too few Chinese documents, which is very inconvenient to use.
The code is as follows, register the control on line 1, add an export button on line 2, and add the UltraWebGridExcelExporter control on line 3.
<%@ Register Assembly=".v5.1, Version=5.1.20051.37, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="" TagPrefix="igxl" %> <asp:button runat="server" Text="Export" Width="64px"></asp:button> <igxl:UltraWebGridExcelExporter ID="UltraWebGridExcelExporter1" runat="server" DownloadName=""></igxl:UltraWebGridExcelExporter> The code is as follows,definitionUltraWebGridExcelExporter,Then callExportfunction。 protected UltraWebGridExcelExporter1; private void Button2_Click(object sender, e){ (this.UltraWebGrid1); }
The above is the entire content of this article, I hope you like it.