Asp.net c # import excel to the mssql SQL database and support multiple sheet tables
Asp tutorial. net c # import excel to mssql SQL database tutorial and support multiple sheet tables
'Solution 1:
ObjSheet = (Excel. _ Worksheet) objSheets. get_Item (Sheets );
'Instance code
For (int I = 0; I <dtData. Rows. Count; I ++)
{
For (int j = 0; j <dtData. Columns. Count-1; j ++)
{
ObjSheet. Cells [I + 2, j + 1] = dtData. Rows [I] [j];
}
}
'
It instance
Excel Data Import SQL server:
SELECT * into newtable
FROM OpenDataSource ('Microsoft. Jet. OLEDB.4.0 ',
'Data Source = "c: book1.xls"; User ID = Admin; Password =; Extended properties = Excel 5.0 ')... [Sheet1 $]
Instance:
SELECT * into newtable
FROM OpenDataSource ('Microsoft. Jet. OLEDB.4.0 ',
'Data Source = "c: Financeaccount.xls"; User ID = Admin; Password =; Extended properties = Excel 5.0 ')... xactions
%>