如何自动添加到Excel文档的Author属性?为此,我想使用c# 4。
发布于 2011-01-18 15:23:38
文档属性此链接说明了如何读取文档属性,并提供了您可以访问的属性列表。
private void DisplayBuiltinDocumentProperties()
{ (Office.DocumentProperties)this.BuiltinDocumentProperties;= Office.DocumentProperties documentProperties1
if (documentProperties1 != null)
{
for (int i = 1; i <= documentProperties1.Count; i++)
{
Office.DocumentProperty dp = documentProperties1[i];
Globals.Sheet1.Range["A" + i.ToString(), missing].Value2 =
dp.Name;
}
}
}
以下是所需的导入列表:
使用Microsoft.Office.Interop.Excel;使用Microsoft.Office.Core;// (Com对象,Office12对象库)`
#en0#a= (Microsoft.Office.Core.DocumentProperties)workbook.BuiltinDocumentProperties;a2.Value =“新作者”;
希望这能有所帮助
发布于 2011-08-18 00:16:36
正如您指定的C# 4一样,您可以使用以下内容:
Workbook wbk = app.Workbooks.Add();
dynamic properties = wbk.BuiltinDocumentProperties;
dynamic property = properties.Item("Author");
property.Value = "J K Rowling";
https://stackoverflow.com/questions/4720825
复制相似问题