using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace 操作Excel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnQuery_Click(object sender, EventArgs e)
{
System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\a.xls;Extended PropertIEs=Excel 8.0;");
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", Conn);//刪除語句沒搞定,有時間了繼續測試。。。
try
{
da.Fill(ds);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);