91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 810B
    文件類型: .zip
    金幣: 2
    下載: 1 次
    發布日期: 2021-06-23
  • 語言: C#
  • 標簽: C#??Excel??

資源簡介

ODBC 引擎,C#讀取Excel,Excel2000,2003,2007等

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Data.OleDb;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;


namespace?ReadExcel07
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}

????????private?void?btnPopulate_Click(object?sender?EventArgs?e)
????????{
????????????//?You?can?change?C:\Members.xlsx?to?any?path?where?
????????????//?the?file?is?located.
????????????string?connectionString?=?@“Provider=Microsoft.ACE.OLEDB.12.0;
???????????????Data?Source=C:\Members.xlsx;Extended?Properties=““Excel?12.0;HDR=YES;“““;

????????????//?if?you?don‘t?want?to?show?the?header?row?(first?row)
????????????//?use?‘HDR=NO‘?in?the?string

????????????string?strSQL?=?“SELECT?*?FROM?[Sheet1$]“;

????????????OleDbConnection?excelConnection?=?new?OleDbConnection(connectionString);
????????????excelConnection.Open();?//?This?code?will?open?excel?file.

????????????OleDbCommand?dbCommand?=?new?OleDbCommand(strSQL?excelConnection);
????????????OleDbDataAdapter?dataAdapter?=?new?OleDbDataAdapter(dbCommand);

????????????//?create?data?table
????????????DataTable?dTable?=?new?DataTable();
????????????dataAdapter.Fill(dTable);

????????????//?bind?the?datasource
????????????dataBingingSrc.DataSource?=?dTable;

????????????//?assign?the?dataBindingSrc?to?the?DataGridView
????????????dgvExcelList.DataSource?=?dataBingingSrc;

????????????//?dispose?used?objects
????????????dTable.Dispose();
????????????dataAdapter.Dispose();
????????????dbCommand.Dispose();

????????????excelConnection.Close();
????????????excelConnection.Dispose();
????????}
????}
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????1767??2007-11-28?17:52??Form1.cs

評論

共有 條評論