我如何读取Excel数据 [英] how can i read excel data
本文介绍了我如何读取Excel数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个程序来读取excel数据并将其转储到所需的数据库中,是否有人可以帮助我解决这个问题?
I want a program to read excel data and dump into my desired database, is there anybody to help me about this
推荐答案
请参见 ^ ].
您可以从Excel文件中检索数据:
You can retrieve data from Excel file:
using Microsoft.Office.Interop.Excel;
Application ExcelObj = new Application();
Workbook theBook = ExcelObj.Workbooks.Open(@"F:\TEMP\1.xlsx", 0, true, 5,"", "", true,Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false,0, true,null,null);
Sheets sheets =theBook.Worksheets;
Worksheet theSheet = (Worksheet)sheets.get_Item(1);
Range range = theSheet.get_Range("A1", "A6");
Array myvalues = (Array)range.Cells.Value2;
foreach (object o in myvalues)
{
Console.WriteLine(o);
}
然后将其写入您的数据库
and then write it to your DB
这篇关于我如何读取Excel数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文