GridView讀取EXCEl並儲存到資料庫中

2021-08-27 02:52:28 字數 1480 閱讀 6092

[email protected]

。。最後將所有源**貼在文章裡。

前台介面顯示

如圖:

**;">

" >

後台**:

using system;

using system.collections;

using system.configuration;

using system.data;

using system.linq;

using system.web;

using system.web.security;

using system.web.ui;

using system.web.ui.htmlcontrols;

using system.web.ui.webcontrols;

using system.web.ui.webcontrols.webparts;

using system.xml.linq;

using system.data.sqlclient;

using system.diagnostics;

using system.io;

using system.collections.generic;

using system.data.oledb;

namespace stas.second

protected void button1_click(object sender, eventargs e)

sqlcommand mycmd = new sqlcommand();

//將資料逐行寫入到資料庫中

for (int i = 0; i < dataset.tables[0].rows.count; i++)

catch (exception ex)}}

response.write("");

if (con.state.tostring() == "open")}

else }

else }

else }

private dataset createdatasource(string path)

protected void bclick(object sender, eventargs e) }

} excel模板如圖:

匯入成功後的介面如下:

資料庫匯入截圖如下:

讀取Excel資料繫結到Gridview進行顯示

讀取excel資料繫結到gridview進行顯示示例 讀取excel datatable public static datatable exceltodatatable string strexcelfilename,string strsheetname strsheetname 這是一種方法 ...

gridview 匯出excel 總結

protected void button1 click object sender,eventargs e private void export string filetype,string filename 如果沒有下面方法會報錯型別 gridview 的控制項 gridview1 必須放在具...

gridview 匯出excel 總結

private void export string filetype,string filename 如果沒有下面方法會報錯型別 gridview 的控制項 gridview1 必須放在具有 runat server 的窗體標記內 public override void verifyrender...