匯出到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
- json陣列匯出到ExcelJSON陣列Excel
- 表結構匯出到excel中Excel
- DataGrid 匯出到 Excel 的幫助類Excel
- Vue+element ui table 匯出到excelVueUIExcel
- 將MYSQL中資料匯出到EXCEL表MySqlExcel
- C# 從datagridview中匯出到excelC#ViewExcel
- 將dataGridView內容匯出到Excel檔案ViewExcel
- LOTUS/DOMINO學習筆記之匯出到EXCEL的方法筆記Excel
- ORACLE資料匯出到Excel、txt、HTML實用方法OracleExcelHTML
- 用SQL Loader將Excel資料匯出到OracleSQLExcelOracle
- 多個報表匯出到一個 excel 的多 sheet 頁Excel
- ASP.NET 2.0匯出到Excel時保留換行的方法ASP.NETExcel
- Java進行excel的匯入匯出操作JavaExcel
- 轉java操作excel匯入匯出JavaExcel
- C# asp.net 把GridView資料 匯出到 ExcelC#ASP.NETViewExcel
- ThinkPHP5.1 Excel 表的匯入匯出操作 (PHPExcel)PHPExcel
- 第四節:海量資料匯出到Excel、百萬Excel匯入到DB、秒級/分鐘級排行版Excel
- Java之POI操作Excel表-匯入匯出JavaExcel
- Dynamics CRM 資料匯出到Excel時列標題不能重複Excel
- 用ExportToXls方法匯出到Excel就變成這樣一團的解決方法ExportExcel
- 轉載:利用SQL*Loader將 Excel 資料匯出到資料庫中SQLExcel資料庫
- MSSQL資料匯出到MYSQLMySql
- Springboot操作Poi進行Excel匯入Spring BootExcel
- Java之POI操作,封裝ExcelUtil實現Excel匯入匯出Java封裝Excel
- Oracle中的表結構匯出到wordOracle
- 資料庫文件編寫,如何通過Navicat把表導成表格?資料庫快速匯出為excel表格資訊,excel匯出到word表格資料庫Excel
- 如何採集地圖上的店鋪把店鋪電話匯出到手機電腦excel地圖Excel
- 大文字資料,匯入匯出到資料庫資料庫
- 利用圖形介面從SQL匯入匯出到MySQLMySql
- poi的excel匯出Excel
- 匯出excelExcel
- EasyPoi, Excel資料的匯入匯出Excel
- vue excel匯入匯出VueExcel
- 【Python】讀取excel並輸出到txtPythonExcel