目前有一个EXCL文件需要读取里面的内容到数据库的指定表,可是不能使用Microsoft.Jet.OLEDB.4.0,请教大家怎么做,最好附代码!
解决方案 »
- vc的dll里输出的参数为wchar_t out10[],在c#中用什么来接,怎么接啊?
- 一个xml与html转换乱码的问题
- C# 往WORD写入文本,关于文本设置字体的问题。
- powershell 管理exchange2007服务器
- 谁来救救我,严重的种族歧视呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ◆◆怎样将数据库的数据替换为datagridview中编辑\添加\删除多条记录后的数据?求函数!!
- 数据库更新操纵时说(MyAdapter.Update(ds,"usermsg");)INSERT INTO 语法错,为什么???
- 高分悬赏UN/EDIFACT和ebXML技术标准
- c#:把路径赋给一个变量的问题,在线等,谢谢!
- 高手,我遇上了一个基础的问题?
- 【100】DataGrid列宽问题
- 求救英语达人
2.如果是2007的版本,用Provider=Microsoft.ACE.OLEDB.12.0;Data Source="路径";
2.如果是2007的版本,用Provider=Microsoft.ACE.OLEDB.12.0;Data Source="路径";》》
不能用Microsoft.Jet.Oledb.4.0
oExcel.DisplayAlerts = false; oBooks = oExcel.Workbooks; oBooks.Open(Excel_Path + File_Name, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
oBook = oBooks.get_Item(1);
oSheets = oBook.Worksheets;
oSheet = (Excel.Worksheet)oSheets.get_Item(1);
oCells = oSheet.Cells;
DataTable dt = new DataTable();
int iRow = 1; while (((Excel.Range)oCells.Cells[iRow, 1]).Text.ToString().Trim() != string.Empty)
{
int iCol = 1;
if (iRow == 1)
{
while (((Excel.Range)oCells.Cells[iRow, iCol]).Text.ToString().Trim() != string.Empty)
{
dt.Columns.Add(((Excel.Range)oCells.Cells[iRow, iCol]).Text.ToString().Trim());
iCol++;
}
}
else
{
DataRow dr = dt.NewRow();
//while (((Excel.Range)oCells.Cells[iRow, iCol]).Text.ToString().Trim() != string.Empty)
//{
for (int i = 1;i<= dt.Columns.Count; i++)
{ dr[i - 1] = ((Excel.Range)oCells.Cells[iRow, i]).Text.ToString().Trim();
iCol++;
}
//}
dt.Rows.Add(dr);
}
iRow++;
}