惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - hone

管理 java学习 服务器相关 总统和亿万富翁经典语录(转载) js学习笔记 最近学习计划 真乱(转自csdn) 沟通(网上搜集) 工作 无题 将文档发送到打印机(From MSN) 经典68个故事 Manually Invalidating All Stale Sessions java的zip压缩(转自Jeet) 图形相关 在Oracle9i中计算时间差 六度分隔 经典故事 新年竟然第一篇?!
VC控制Excel
hone · 2007-01-12 · via 博客园 - hone

关于Excel的操作,代码来源自网络。

 1void CControlExcelDoc::OnControlExcel() 
 2{
 3    // TODO: Add your command handler code here
 4    COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,
 5        VT_ERROR),vtTrue((short)TRUE),vtFalse((short)FALSE);
 6    _Application *ExcelApp = new _Application;
 7
 8    ExcelApp->CreateDispatch("excel.application");
 9
10    //设置为显示
11    ExcelApp->SetVisible(TRUE);
12    //得到WorkBooks
13    Workbooks  ExcelBook=ExcelApp->GetWorkbooks();
14    Sheets     ExcelSheet=ExcelBook.Add(vtOptional);
15    _Workbook  workBook;
16    _Worksheet workSheet;
17    Range    range;
18    workBook.AttachDispatch(ExcelApp->GetApplication());
19    ExcelSheet=workBook.GetSheets();
20
21    ////////////////////////////////////////////
22    workSheet=ExcelSheet.GetItem(COleVariant((short)1));
23    workSheet.Activate();
24
25
26    Range myallrange=workSheet.GetRange(COleVariant("A1"),COleVariant("D1"));
27    //myallrange.BorderAround(COleVariant((short)1),(long)2,(long)1,vtOptional);
28    myallrange.SetHorizontalAlignment(COleVariant((short)3));
29    myallrange.Merge(COleVariant((short)1));
30    myallrange.SetValue(COleVariant("个人信息表"));
31
32    Range myrange=workSheet.GetRange(COleVariant("A2"),COleVariant("A2"));
33    myrange.SetValue(COleVariant("姓名"));
34    myrange.BorderAround(COleVariant((short)1),(long)2,(long)1,vtOptional);
35    myrange.SetHorizontalAlignment(COleVariant((short)3));
36    myrange.SetVerticalAlignment(COleVariant((short)2));
37    myrange.SetColumnWidth(COleVariant((short)15));
38
39    myrange=workSheet.GetRange(COleVariant("B2"),COleVariant("B2"));
40    myrange.SetValue(COleVariant("性别"));
41    myrange.BorderAround(COleVariant((short)1),(long)2,(long)1,vtOptional);
42    myrange.SetHorizontalAlignment(COleVariant((short)3));
43    myrange.SetVerticalAlignment(COleVariant((short)2));
44    myrange.SetColumnWidth(COleVariant((short)15));
45
46    myrange=workSheet.GetRange(COleVariant("C2"),COleVariant("C2"));
47    myrange.SetValue(COleVariant("QQ"));
48    myrange.BorderAround(COleVariant((short)1),(long)2,(long)1,vtOptional);
49    myrange.SetHorizontalAlignment(COleVariant((short)3));
50    myrange.SetVerticalAlignment(COleVariant((short)2));
51    myrange.SetColumnWidth(COleVariant((short)15));
52
53    myrange=workSheet.GetRange(COleVariant("D2"),COleVariant("D2"));
54    myrange.SetValue(COleVariant("Email"));
55    myrange.BorderAround(COleVariant((short)1),(long)2,(long)1,vtOptional);
56    myrange.SetHorizontalAlignment(COleVariant((short)3));
57    myrange.SetVerticalAlignment(COleVariant((short)2));
58    myrange.SetColumnWidth(COleVariant((short)17));
59
60    CString str;
61    for(int i=3;i<=500;i++)
62    {
63        str.Format("A%d",i);
64        Range myrange=workSheet.GetRange(COleVariant(str),COleVariant(str));
65        myrange.SetValue(COleVariant("名字"));
66        myrange.BorderAround(COleVariant((short)1),(long)2,(long)1,vtOptional);
67        myrange.SetHorizontalAlignment(COleVariant((short)3));
68        myrange.SetVerticalAlignment(COleVariant((short)2));
69
70        str.Format("B%d",i);
71        myrange=workSheet.GetRange(COleVariant(str),COleVariant(str));
72        myrange.SetValue(COleVariant(""));
73        myrange.BorderAround(COleVariant((short)1),(long)2,(long)1,vtOptional);
74        myrange.SetHorizontalAlignment(COleVariant((short)3));
75        myrange.SetVerticalAlignment(COleVariant((short)2));
76
77        str.Format("C%d",i);
78        myrange=workSheet.GetRange(COleVariant(str),COleVariant(str));
79        myrange.SetValue(COleVariant("12345678"));
80        myrange.BorderAround(COleVariant((short)1),(long)2,(long)1,vtOptional);
81        myrange.SetHorizontalAlignment(COleVariant((short)3));
82        myrange.SetVerticalAlignment(COleVariant((short)2));
83
84        str.Format("D%d",i);
85        myrange=workSheet.GetRange(COleVariant(str),COleVariant(str));
86        myrange.SetValue(COleVariant("superxsc@126.com"));
87        myrange.BorderAround(COleVariant((short)1),(long)2,(long)1,vtOptional);
88        myrange.SetHorizontalAlignment(COleVariant((short)3));
89        myrange.SetVerticalAlignment(COleVariant((short)2));
90    }

91
92    delete ExcelApp;
93
94}