1、创建一个新的工作簿

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

2、打开一个工作簿

this.Application.Workbooks.Open(@"C:\Test\YourWorkbook.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);

 

相关文章:

  • 2021-12-05
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
  • 2021-12-15
  • 2022-12-23
  • 2021-11-03
猜你喜欢
  • 2022-12-23
  • 2021-11-18
  • 2022-01-13
  • 2021-05-25
  • 2021-06-02
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案