匯出到Excel的操作
1
2 DataTable dt = wad.GetToExcel(lblcode.Text);
3 StringWriter sw = new StringWriter();
4
5 sw.WriteLine("代號,貨品編碼,貨品名稱,單位,淨需求量,採購量,供應商,下單日期,到貨日期,採購員,報關,狀態,採購訂單號");
6 foreach (DataRow item in dt.Rows)
7 {
8 //string state = (OPSState)Convert.ToInt32(item["imgstate"]);
9 sw.WriteLine(item["code"] + "," + item["goodscode"] + "," +
10 item["goodsname"] + "," + item["unit"] + "," +
11 item["netdemand"] + "," + item["shoppingnum"] + "," +
12 item["tradername"] + "," + item["orderdate"] + "," +
13 item["arrivaldate"] + "," + item["buyername"] + "," +
14 item["ifcustoms"] + "," + (OPSState)Convert.ToInt32(item["imgstate"]) + "," +
15 item["ordercode"] );
16 }
17 Response.AddHeader("Content-Disposition", "attachment; filename=test.csv");
18 Response.ContentType = "application/ms-excel";
19 Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
20 Response.Write(sw);
21 sw.Close();
22 Response.End();
2 DataTable dt = wad.GetToExcel(lblcode.Text);
3 StringWriter sw = new StringWriter();
4
5 sw.WriteLine("代號,貨品編碼,貨品名稱,單位,淨需求量,採購量,供應商,下單日期,到貨日期,採購員,報關,狀態,採購訂單號");
6 foreach (DataRow item in dt.Rows)
7 {
8 //string state = (OPSState)Convert.ToInt32(item["imgstate"]);
9 sw.WriteLine(item["code"] + "," + item["goodscode"] + "," +
10 item["goodsname"] + "," + item["unit"] + "," +
11 item["netdemand"] + "," + item["shoppingnum"] + "," +
12 item["tradername"] + "," + item["orderdate"] + "," +
13 item["arrivaldate"] + "," + item["buyername"] + "," +
14 item["ifcustoms"] + "," + (OPSState)Convert.ToInt32(item["imgstate"]) + "," +
15 item["ordercode"] );
16 }
17 Response.AddHeader("Content-Disposition", "attachment; filename=test.csv");
18 Response.ContentType = "application/ms-excel";
19 Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
20 Response.Write(sw);
21 sw.Close();
22 Response.End();
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12639172/viewspace-618271/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- hive匯出到csv hive匯出到excelHiveExcel
- java 匯出到EXCELJavaExcel
- fastadmin的匯出到excel功能ASTExcel
- 將資料匯出到ExcelExcel
- Vue+element ui table 匯出到excelVueUIExcel
- 將dataGridView內容匯出到Excel檔案ViewExcel
- 多個報表匯出到一個 excel 的多 sheet 頁Excel
- Java進行excel的匯入匯出操作JavaExcel
- ThinkPHP5.1 Excel 表的匯入匯出操作 (PHPExcel)PHPExcel
- 第四節:海量資料匯出到Excel、百萬Excel匯入到DB、秒級/分鐘級排行版Excel
- Java之POI操作Excel表-匯入匯出JavaExcel
- Dynamics CRM 資料匯出到Excel時列標題不能重複Excel
- Springboot操作Poi進行Excel匯入Spring BootExcel
- MSSQL資料匯出到MYSQLMySql
- Java之POI操作,封裝ExcelUtil實現Excel匯入匯出Java封裝Excel
- 如何將simulink的影像匯出到VISIO中
- 如何採集地圖上的店鋪把店鋪電話匯出到手機電腦excel地圖Excel
- 大文字資料,匯入匯出到資料庫資料庫
- poi的excel匯出Excel
- 資料庫文件編寫,如何通過Navicat把表導成表格?資料庫快速匯出為excel表格資訊,excel匯出到word表格資料庫Excel
- 匯出excelExcel
- EasyPoi, Excel資料的匯入匯出Excel
- vue excel匯入匯出VueExcel
- Unity匯出到Xcode沒有Run Destination的問題UnityXCode
- 一個通用的匯入匯出excel的思路Excel
- 關於java中Excel的匯入匯出JavaExcel
- EasyExcel完成excel檔案的匯入匯出Excel
- excel的匯入與匯出---通用版Excel
- 如何將資料熱匯出到檔案
- Angular Excel 匯入與匯出AngularExcel
- Excel匯入匯出神器(Java)ExcelJava
- VNPY 批量優化引數,並輸出到excel優化Excel
- excel匯入工具Excel
- Java匯出ExcelJavaExcel
- Vue匯出ExcelVueExcel
- excel匯出工具Excel
- PHP 匯出 ExcelPHPExcel
- PHP匯出EXCELPHPExcel
- 使用 Laravel-Excel 和流的方法匯出 ExcelLaravelExcel