16 workbook.set_properties()

优质
小牛编辑
121浏览
2023-12-01

set_properties(properties) Set the document properties such as Title, Author etc. 设置文档的属性值,比如标题、作者等。

  • Parameters:
    • properties (字典) – 文档属性的字典。

set_properties()方法可以用来设置创建的XLSX文件的文档属性。当你在Excel中点击Office按钮 ->准备 ->文档属性时,可以看到这些属性。同时,对读取和索引Windows文件的外部应用程序来说,他们也是可见的。

The properties that can be set are: 属性字典中可以设置如下属性:

  • title
  • subject
  • author
  • manager
  • company
  • category
  • keywords
  • comments
  • status
  • hyperlink_base
  • create - 文件的创建时间为一个 datetime.date 对象。

这些属性都是可选的,值以字典的形式传递,如下所示:

workbook.set_properties({
    'title':    'This is an example spreadsheet',
    'subject':  'With document properties',
    'author':   'John McNamara',
    'manager':  'Dr. Heinz Doofenshmirtz',
    'company':  'of Wolves',
    'category': 'Example spreadsheets',
    'keywords': 'Sample, Example, Properties',
    'created':  datetime.date(2018, 1, 1),
    'comments': 'Created with Python and XlsxWriter'})