Tag: webmethod

将数据集导出到Excel,并从asp.net Web方法提出文件下载对话框

我正在使用下面的代码将数据集导出到Excel工作表。 [WebMethod] public static void ExporttoExcel() { DataSet ds; productfactory pf=new productfactory(); ds = pf.getproducts(); HttpResponse response = HttpContext.Current.Response; // first let's clean up the response.object response.Clear(); response.Charset = ""; response.ContentEncoding = System.Text.Encoding.Default; // set the response mime type for excel response.ContentType = "application/vnd.ms-excel"; response.AddHeader("Content-Disposition", "attachment;filename=\"products.xls\""); // create a string writer using (StringWriter sw = […]