Microsoft.Office.Interop.Excel 命名空间里 workbook有此类属性吗
那些都在FileInfo里面
你using System.IO就可以用了
通过nuget搜索“Free Spire.XLS”,安装,然后参考下面的代码来设置文档相关属性:
using Spire.Xls;
using System;
namespace AddProperties
{
class Program
{
static void Main(string[] args)
{
//加载Excel文档
Workbook workbook = new Workbook();
workbook.LoadFromFile("test.xlsx");
//设置摘要
workbook.DocumentProperties.Author = "Mara";
workbook.DocumentProperties.Title = "摘要";
workbook.DocumentProperties.Keywords = "摘要,属性";
workbook.DocumentProperties.Category = "展示文档";
workbook.DocumentProperties.Company = "某某公司";
workbook.DocumentProperties.Comments = "请勿修改";
workbook.DocumentProperties.Subject = "测试";
workbook.DocumentProperties.Manager = "Tom";
//设置自定义属性
workbook.CustomDocumentProperties.Add("_MarkAsFinal", true);
workbook.CustomDocumentProperties.Add("联系电话", 1234567);
workbook.CustomDocumentProperties.Add("更新时间", DateTime.Now);
//保存文档
workbook.SaveToFile("AddProperties.xlsx", FileFormat.Version2010);
System.Diagnostics.Process.Start("AddProperties.xlsx");
}
}
}