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

推荐订阅源

N
News and Events Feed by Topic
D
Docker
云风的 BLOG
云风的 BLOG
F
Fortinet All Blogs
F
Full Disclosure
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
L
LangChain Blog
H
Help Net Security
B
Blog
T
Tailwind CSS Blog
V
V2EX
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
美团技术团队
A
About on SuperTechFans
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
I
InfoQ
Project Zero
Project Zero
I
Intezer
Google DeepMind News
Google DeepMind News
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Threat Research - Cisco Blogs
Last Week in AI
Last Week in AI
C
Cyber Attacks, Cyber Crime and Cyber Security
G
GRAHAM CLULEY
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AWS News Blog
AWS News Blog
Spread Privacy
Spread Privacy
S
Securelist
Recorded Future
Recorded Future
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 叶小钗
S
Security Affairs
Blog — PlanetScale
Blog — PlanetScale
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
The Hacker News
The Hacker News

博客园 - DarroldYang

linux 多线程,锁同步 Saas模式数据库层数据架构以及数据删除处理 ASP.NET MVC 自定义过滤属性实现Enterprise的log功能 ASP.NET MVC 请求生命周期 ASP.NET MVC HtmlHelper类的方法总结 - DarroldYang (Windows 7 IIS 7.5里面的 IIS and Built-in Accounts) IIS和内置帐户的IIS 用户控件,事件的触发顺序 IIS7.0 An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode 转ORACLE函数大全 ASP.NET AJAX 调用Service Method (Too simply) Office编程知识点汇总(3)--格式设置 Office编程知识点汇总(2)--基本工作表任务 asp.NET应用程序的技巧 CrystalReport的导出“Push”方式 Ajax Control Toolkit MutuallyExclusiveCheckBox 服务器端控件 Ajax Control Toolkit Slider 服务器端控件 Ajax Control Toolkit AlwaysVisibleControl 服务器端控件 Ajax Control Toolkit Accordion 服务器端控件 判断代码执行环境
Office编程知识点汇总:基本工作簿任务
DarroldYang · 2009-05-14 · via 博客园 - DarroldYang

        日常Office编程知识积累!方便速查,使用!

 1(1)打开现有工作簿
 2     this.Application.Workbooks.Open(@"C:\YourPath\YourWorkbook.xls",
 3     missing, missing, missing, missing, missing, missing, missing,
 4     missing, missing, missing, missing, missing,missing, missing);
 5   以工作簿形式打开文本文件
 6     this.Application.Workbooks.OpenText(@"C:\Test.txt",
 7    missing, 3,
 8    Excel.XlTextParsingType.xlDelimited,
 9    Excel.XlTextQualifier.xlTextQualifierNone,
10    missing, missing, missing, true, missing, missing, missing, 
11    missing, missing, missing, missing, missing, missing);
12(2)激活工作簿
13   使用 Workbooks 集合的 Activate 方法。
14    ((Microsoft.Office.Interop.Excel._Workbook)
15    this.Application.Workbooks[1]).Activate();
16   使用 ThisWorkbook 激活工作簿。
17     Globals.ThisWorkbook.Activate();
18   引用各个工作簿
19     Excel.Workbook wb = this.Application.Workbooks[1];
20    wb = this.Application.Workbooks["Book1"];
21    wb = this.Application.Workbooks["Book1.xls"];
22(3)保存所有打开的工作簿
23   foreach (Excel.Workbook wkb in this.Application.Workbooks) 
24   {
25      wkb.Save();
26   }

27   SaveAs 方法
28    SaveAs 方法比 Save 方法复杂。使用此方法可以将指定的工作簿保存到新位置,或以新名称保存,并可选择指定文件格式、密码、访问模式等。
29  this.SaveAs(@"C:\Book1.xml", Excel.XlFileFormat.xlXMLSpreadsheet,
30    missing, missing, missing, missing, Excel.XlSaveAsAccessMode.xlNoChange,
31    missing, missing, missing, missing, missing);
32(4)以编程方式通过电子邮件发送工作簿
33    将工作簿作为电子邮件附件发送
34       调用工作簿的 SendMail 方法并指定收件人,还可以选择指定主题。
35         Globals.ThisWorkbook.SendMail("someone@example.com""July Sales Figures", missing);
36(5)显示对话框以打开 Excel 文件
37  Microsoft.Office.Core.FileDialog fd = 
38    this.Application.get_FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogOpen);
39
40    fd.AllowMultiSelect = true
41    fd.Filters.Clear(); 
42    fd.Filters.Add("Excel Files""*.xls;*.xlw", missing); 
43    fd.Filters.Add("All Files""*.*", missing); 
44
45    if (fd.Show() != 0)
46    {
47      fd.Execute();
48    }

49(6)列出最近使用的工作簿文件
50    Microsoft.Office.Tools.Excel.NamedRange nr;
51    nr = this.Controls.AddNamedRange(this.Range["A1", missing], "Files");
52
53   for(int i=1; i<=this.Application.RecentFiles.Count; i++)
54   {
55     nr.Offset[i - 10].Value2 = this.Application.RecentFiles.get_Item(i).Name;
56   }