发布网友 发布时间:2024-10-23 22:41
共1个回答
热心网友 时间:2024-10-27 19:38
读取Excel文件属性么?可参考如下方法,包括自定义属性值:
using Spire.Xls;
using Spire.Xls.Collections;
using Spire.Xls.Core;
using System;
namespace ReadProperties
{
class Program
{
static void Main(string[] args)
{
//加载Excel文档
Workbook wb = new Workbook();
wb.LoadFromFile("AddProperties.xlsx");
//获取文档属性
Console.WriteLine("摘要信息:");
Console.WriteLine("标题: " + wb.DocumentProperties.Title);
Console.WriteLine("主题: " + wb.DocumentProperties.Subject);
Console.WriteLine("作者: " + wb.DocumentProperties.Author);
Console.WriteLine("管理者: " + wb.DocumentProperties.Manager);
Console.WriteLine("公司: " + wb.DocumentProperties.Company);
Console.WriteLine("类别: " + wb.DocumentProperties.Category);
Console.WriteLine("关键字: " + wb.DocumentProperties.Keywords);
Console.WriteLine("备注: " + wb.DocumentProperties.Comments);
//获取自定义属性
Console.WriteLine("\n自定义属性:");
for (int i = 0; i < wb.CustomDocumentProperties.Count; i++)
{
Console.WriteLine(wb.CustomDocumentProperties[i].Name + ": " + wb.CustomDocumentProperties[i].Value);
}
Console.Read();
}
}
}
属性值读取结果:
程序中引入spire.xls.dll程序集文件。