如何在C#Sharp.net Windows应用程序中将Excel工作表添加为ole对象 [英] how to add excel sheet as ole objects in c# sharp.net windows application

查看:77
本文介绍了如何在C#Sharp.net Windows应用程序中将Excel工作表添加为ole对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生!
我想将访问文件或Excel工作表添加为ole对象.
我该怎么做.

Dear sir!
I want to add access file or excel sheet as ole objects.
how can i do this.
which property of the form will be used.

推荐答案

与此类似.只是一个猜测.

something similar to this. just a guess.

using System.Data.OleDb;





string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\Somehwere\\Somehwere\\App_Data\\FILE.xls; Extended Properties=Excel 8.0;";

//You must use the


after the object you reference in the spreadsheet OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [Sheet1
after the object you reference in the spreadsheet OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [Sheet1


", strConn); DataSet myDataSet = new DataSet(); myCommand.Fill(myDataSet, "ExcelInfo"); foreach (DataRow theRow in myDataSet.Tables["ExcelInfo"].Rows) { Console.WriteLine(theRow[0].ToString()); }
", strConn); DataSet myDataSet = new DataSet(); myCommand.Fill(myDataSet, "ExcelInfo"); foreach (DataRow theRow in myDataSet.Tables["ExcelInfo"].Rows) { Console.WriteLine(theRow[0].ToString()); }


这篇关于如何在C#Sharp.net Windows应用程序中将Excel工作表添加为ole对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆