asp教程.net c# 把excel导入mssql sql数据库教程并支持多个sheet表
'解决方法一
objSheet = (Excel._Worksheet)objSheets.get_Item(Sheets);
'实例代码
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];
}
}'其
它实例
Excel的数据导入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$]
实例:
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
%>