zoukankan      html  css  js  c++  java
  • VSTO开发之一 工作簿的操作

    1、创建一个新的工作簿

    Excel.Workbook newWorkbook = this.Application.Workbooks.Add();

    2、打开一个工作簿

    this.Application.Workbooks.Open(@"C:TestYourWorkbook.xlsx");

    3、关闭一个工作簿

    Globals.ThisWorkbook.Close(false);
    
    this.Application.ActiveWorkbook.Close(false, missing, missing);

    4、保存一个工作簿

    this.Save();
    this.Application.ActiveWorkbook.Save();

    5、以编程的方式保护文档

    this.Protect(getPasswordFromUser, missing, missing);
    this.Unprotect(getPasswordFromUser);

    6、编程方式列出最近使用的工作簿文件

    Excel.Range rng = this.Application.get_Range("A1");
    for(int i=1; i<=this.Application.RecentFiles.Count; i++) {
     rng.get_Offset(i - 1,0).Value2 = this.Application.RecentFiles.get_Item(i).Name; 
    }

    7、以编程方式及工作簿形式打开文本文件

    this.Application.Workbooks.OpenText(@"C:Test.txt", missing, 3, Excel.XlTextParsingType.xlDelimited, Excel.XlTextQualifier.xlTextQualifierNone, missing, missing, missing, true, missing, missing, missing, missing, missing, missing, missing, missing, missing);
  • 相关阅读:
    Python 使用正则表达式匹配URL网址
    第3章 网络爬虫基础
    《精通Python网络爬虫》
    /etc/hosts
    Linux alias 命令
    file()
    Win10 取消桌面快捷键图标
    Win10 我的电脑 -- 右键点击管理打不开
    MongoDB 备份恢复
    ORACLE 日期比较
  • 原文地址:https://www.cnblogs.com/minhost/p/7932427.html
Copyright © 2011-2022 走看看