工作之余,把做工程過程中重要的代碼段做個(gè)記錄,如下的資料是關(guān)于C#使用Ado.net讀取Excel表的代碼,應(yīng)該能對(duì)各位有所幫助。
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了鐵西免費(fèi)建站歡迎大家使用!
using System;
using System.Data.OleDb;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
string connString = "Provider=Microsoft.Jet.OleDb.4.0; data source=c:\sample.xls; Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(connString);
OleDbCommand cmd = new OleDbCommand(selectqry,con);
try
{
con.Open();
OleDbDataReader theDatardr = cmd.ExecuteReader();
while (theDatardr.Read())
{
Console.WriteLine("{0}: {1} ({2}) – {3} ({4})", theDatardr.GetString(0),theDatardr.GetString(1),theDatardr.GetString(2),theDatardr.GetString(3),theDatardr.GetString(4));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
con.Dispose();
}
}
}
}
網(wǎng)站名稱:C#使用Ado.net讀取Excel表的代碼
鏈接URL:http://chinadenli.net/article18/ppchgp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、靜態(tài)網(wǎng)站、全網(wǎng)營銷推廣、網(wǎng)站排名、定制網(wǎng)站、網(wǎng)頁設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)