본문 바로가기

컴퓨터/언어,프로그래밍

[스크랩] Excel 데이터를 C#으로 읽을 때

         public void Read()

16     {
17         try
18         {
19             string ExcelFile = "test.xls";
20             string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"+
21                 "Data Source=c:\\myoun\\test.xls;"+"Extended Properties=Excel 8.0;";
22
23             OleDbConnection conn = new OleDbConnection(ConnectionString);
24             OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Items", conn);
25
26             conn.Open();
27             MyDataSet = new DataSet("MyDataSet");
28             da.FillSchema(ds, SchemaType.Source, ExcelFile);
29             da.Fill(ds, ExcelFile);
30
31             //make changes to dataset
32             conn.Close();
33
34         }
35         catch(Exception e)
36         {
37             Console.WriteLine(e);
38         }
39     }

 

출처 : http://blog.naver.com/lovemingai/120056857053





제주삼다수, 2L,... 오뚜기 진라면 매운... 상하목장 유기농 흰... 남양 프렌치카페 카... 고려인삼유통 홍삼 ... 종근당건강 오메가3... 요이치 카링 유무선...