如何用asp.net將sql資料寫入excel?
請輸入專案類型(網站專案或者應用程式專案):
這是小弟第一次問問題,若有錯的話,還請多多包含
問題如標題:
目前只能把sql資料表的欄位名稱寫入excel裡面,但值總是抓不到,不知抓值的那
段程式大概要怎樣寫,還請有經驗的大大幫個忙。
以下是部分程式:
string test = string.Empty;
foreach (DataColumn Cell in DS.Tables[0].Columns)//欄位...
{
if (test != string.Empty)
{
test += ",";
}
test += Cell.ColumnName;
}
SW.WriteLine(test);
------------------上面以可以顯示欄位名稱-----------------------
foreach (DataRow DR in DS.Tables[0].Rows) //欄位值
{
//string test2=string.Empty;
foreach (DataColumn Cell in DS.Tables[0].Columns)
{
//string test2=DR.Table.Rows[0][
//SW.WriteLine(test2);
---------------欄位值寫不出來,還請各位前輩多多指教一下謝謝--------
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 36.234.41.200