設定OWC axSpreadsheet控制項資料來源

2022-01-17 09:31:04 字數 3962 閱讀 9154

1:新增元件到控制項工具箱

2:新增控制項到窗體

3:新增c#**

using system;

2:

using system.collections.generic;

3:

using system.componentmodel;

4:

using system.data;

5:

using system.drawing;

6:

using system.linq;

7:

using system.text;

8:

using system.windows.forms;

9:
10:11:
18:         datatable dt = null;
19:

private

void buttonx1_click(object sender, eventargs e)

20:         ;server=tel-236a\ztxsql2000;uid=sa;pwd=330443137; database=tbmrp";
24:             conn.open(str, "", "", -1);
25:             rs.activeconnection = conn;
26:             rs.cursortype = adodb.cursortypeenum.adopenstatic;
27:             rs.cursorlocation = adodb.cursorlocationenum.aduseclient;
28:
29:

string sql = "select * from pncolor";

30:             rs.open(sql, conn, adodb.cursortypeenum.adopenstatic, adodb.locktypeenum.adlockoptimistic, 1);
31:
32:
33:

//// dt = new datatable();

34:

// dt.columns.add("a");

35:

// dt.rows.add(dt.newrow());

36:             ((microsoft.office.interop.owc11.worksheet)this.axspreadsheet1.worksheets["sheet1"]).range["a1:z65536"].copyfromrecordset(rs);
37:

// ((microsoft.office.interop.owc11.worksheet)this.axspreadsheet1.worksheets[0]).commandtext = "select * from pncolor";

38:

//((microsoft.office.interop.owc11.worksheet)this.axspreadsheet1.worksheets[0]).refresh();

39:

this.axpivottable1.datasource = (msdatasrc.datasource)rs;

40:
41:             ((microsoft.office.interop.owc11.worksheet)this.axspreadsheet1.worksheets["sheet1"]).range["a2"].select();
42:

this.axspreadsheet1.activewindow.freezepanes = true;

43:         }
44:
45:

private

void buttonx3_click(object sender, eventargs e)

46:         ;server=tel-236a\ztxsql2000;uid=sa;pwd=330443137; database=tbmrp";
50:             conn.open(str, "", "", -1);
51:             rs.activeconnection = conn;
52:             rs.cursortype = adodb.cursortypeenum.adopenstatic;
53:             rs.cursorlocation = adodb.cursorlocationenum.aduseclient;
54:
55:

string sql = "select top 200 'a' as [一],* from pncoptc";

56:             rs.open(sql, conn, adodb.cursortypeenum.adopenstatic, adodb.locktypeenum.adlockoptimistic, 1);
57:
58:
59:

//// dt = new datatable();

60:

// dt.columns.add("a");

61:

// dt.rows.add(dt.newrow());

62:             ((microsoft.office.interop.owc11.worksheet)this.axspreadsheet1.worksheets["sheet1"]).range["a1:z65536"].copyfromrecordset(rs);
63:

// ((microsoft.office.interop.owc11.worksheet)this.axspreadsheet1.worksheets[0]).commandtext = "select * from pncolor";

64:

//((microsoft.office.interop.owc11.worksheet)this.axspreadsheet1.worksheets[0]).refresh();

65:

this.axpivottable1.datasource = (msdatasrc.datasource)rs;

66:         }
67:
68:
69:     }
70: }
4:測試程式

注:一直沒有找到給axspreadsheet設定資料來源的方法,今天做excel vba開發時起到了copyfromrecordset方法,一試居然就行了。axpivottable資料透視表的功能相當強大,只是介面單調了些,還有就是沒有直接列印的方法。

儲存設定 設定 CATIA自動儲存設定

問題 在使用catia設計時,大約每隔半小時就會遇到一次 卡死 特別是設計任務較為複雜時,卡死 的時間會較長,此時我們只好暫停設計工作,等待恢復 多數情況下 這是catia在自動儲存時的 卡滯 而不是真正的 卡死 目的就是防止沒有主動儲存習慣的小夥伴,遇見 意外情況 真正 卡死 後,重啟catia還...

pycharm 常用設定設定

1.自動加冒號 換行 complete current statement ctrl shift enter 與虛擬機器衝突 修改為 ctrl shift 2.儲存成模板 ctrl shift l live template 3.設定 pycharm 注釋字型顏色 setting font lang...

linux centos ip設定網絡卡設定

1 自動獲取ip位址 虛擬機器使用橋接模式,相當於連線到物理機的網路裡,物理機網路有dhcp伺服器自動分配ip位址。dhclient 自動獲取ip位址命令 ifconfig 查詢系統裡網絡卡資訊,ip位址 mac位址 分配到ip位址後,用物理機進行ping ip位址,檢測是否ping通。2 手動設定...