xlsx/custom-properties-types

The ``docProps/custom.xml`` part stores user-defined name/value pairs with a typed child from the ``vt:`` namespace. This family covers one case per type python-xlsx can emit -- lpwstr, bool, i4, r8, filetime, and date -- exercising the full CustomDocumentProperties value-type mapping.

Cases (6)

Feature IDAxis bindingspython-xlsxxlsxjs
xlsx/custom-properties-types--booltype=bool
xlsx/custom-properties-types--datetype=date
xlsx/custom-properties-types--filetimetype=filetime
xlsx/custom-properties-types--i4type=i4
xlsx/custom-properties-types--lpwstrtype=lpwstr
xlsx/custom-properties-types--r8type=r8

Aggregate

LibraryPassFailPending
python-xlsx006
xlsxjs006

Parameter axes

Spec notes

python-xlsx's ``Workbook.custom_doc_props`` is a typed mapping: ``str`` -> ``vt:lpwstr``, ``int`` -> ``vt:i4``, ``float`` -> ``vt:r8``, ``bool`` -> ``vt:bool``, ``datetime.datetime`` -> ``vt:filetime``, ``datetime.date`` -> ``vt:date``. As of Wave 8 (W8-E), python-docx and python-pptx also emit ``vt:date`` from ``datetime.date``, so the three libraries are now at parity on this type table.

Generator source

scripts/gen_custom_properties_types_xlsx.py — runs with --arg_template --type {type.id} --value "{type.value}" --out fixtures/xlsx/custom-properties-types--{type.id}.xlsx

#!/usr/bin/env python3
"""Generate ``fixtures/xlsx/custom-properties-types--<type>.xlsx`` fixtures.

Parameterised generator; drives ``features/xlsx/custom-properties-types.json``.
Unique to xlsx: the ``date`` case exercises python-xlsx's ``datetime.date`` ->
``vt:date`` mapping (docx / pptx don't currently expose vt:date).
"""

from __future__ import annotations

import argparse
import datetime as _dt
from pathlib import Path

from xlsx import Workbook

_REPO_ROOT = Path(__file__).resolve().parent.parent
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)

_PINNED_CREATED = _dt.datetime(2026, 1, 1, 0, 0, 0)
_PINNED_MODIFIED = _dt.datetime(2026, 1, 2, 0, 0, 0)


def _coerce(vt_id: str, value: str):
    if vt_id == "lpwstr":
        return value
    if vt_id == "bool":
        return value.lower() == "true"
    if vt_id == "i4":
        return int(value)
    if vt_id == "r8":
        return float(value)
    if vt_id == "filetime":
        return _dt.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S")
    if vt_id == "date":
        return _dt.date.fromisoformat(value)
    raise SystemExit(f"Unknown vt type id: {vt_id!r}")


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("--type", dest="type_id", required=True)
    parser.add_argument("--value", required=True)
    parser.add_argument(
        "--out",
        default=str(_REPO_ROOT / "fixtures" / "xlsx" / "custom-properties-types.xlsx"),
    )
    args = parser.parse_args()

    out_path = Path(args.out)
    if not out_path.is_absolute():
        out_path = _REPO_ROOT / out_path

    wb = Workbook()
    wb.properties.created = _PINNED_CREATED
    wb.properties.modified = _PINNED_MODIFIED
    wb.properties.creator = ""
    wb.custom_doc_props["TestProp"] = _coerce(args.type_id, args.value)
    out_path.parent.mkdir(parents=True, exist_ok=True)
    wb.save(out_path, zip_date_time=_REPRODUCIBLE_DT)
    print(out_path)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

Manifest (parent, unexpanded)

{
  "$schema": "../manifest.schema.json",
  "id": "xlsx/custom-properties-types",
  "kind": "parameterised",
  "title": "Custom document properties: one case per vt: type",
  "format": "xlsx",
  "category": "metadata",
  "summary": "The ``docProps/custom.xml`` part stores user-defined name/value pairs with a typed child from the ``vt:`` namespace. This family covers one case per type python-xlsx can emit -- lpwstr, bool, i4, r8, filetime, and date -- exercising the full CustomDocumentProperties value-type mapping.",
  "spec": {
    "source": "ecma-376-5-part-2",
    "clause": "11.2",
    "notes": "python-xlsx's ``Workbook.custom_doc_props`` is a typed mapping: ``str`` -> ``vt:lpwstr``, ``int`` -> ``vt:i4``, ``float`` -> ``vt:r8``, ``bool`` -> ``vt:bool``, ``datetime.datetime`` -> ``vt:filetime``, ``datetime.date`` -> ``vt:date``. As of Wave 8 (W8-E), python-docx and python-pptx also emit ``vt:date`` from ``datetime.date``, so the three libraries are now at parity on this type table."
  },
  "fixtures": {
    "machine": "xlsx/custom-properties-types"
  },
  "generator": {
    "python": "scripts/gen_custom_properties_types_xlsx.py",
    "arg_template": "--type {type.id} --value \"{type.value}\" --out fixtures/xlsx/custom-properties-types--{type.id}.xlsx"
  },
  "parameters": {
    "type": [
      {
        "id": "lpwstr",
        "value": "hello world",
        "vt_element": "lpwstr",
        "vt_value": "hello world"
      },
      {
        "id": "bool",
        "value": "true",
        "vt_element": "bool",
        "vt_value": "true"
      },
      {
        "id": "i4",
        "value": "42",
        "vt_element": "i4",
        "vt_value": "42"
      },
      {
        "id": "r8",
        "value": "3.14159",
        "vt_element": "r8",
        "vt_value": "3.14159"
      },
      {
        "id": "filetime",
        "value": "2026-01-15T12:30:45",
        "vt_element": "filetime",
        "vt_value": "2026-01-15T12:30:45Z"
      },
      {
        "id": "date",
        "value": "2026-01-15",
        "vt_element": "date",
        "vt_value": "2026-01-15"
      }
    ]
  },
  "assertions_template": [
    {
      "id": "custom-{type.id}-present",
      "part": "docProps/custom.xml",
      "namespaces": {
        "op": "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
        "vt": "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"
      },
      "xpath": "//op:property[@name='TestProp']/vt:{type.vt_element}",
      "must": "exist",
      "description": "TestProp must carry a <vt:{type.vt_element}> child."
    },
    {
      "id": "custom-{type.id}-value",
      "part": "docProps/custom.xml",
      "namespaces": {
        "op": "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
        "vt": "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"
      },
      "xpath": "//op:property[@name='TestProp']/vt:{type.vt_element}",
      "must": "equal",
      "value": "{type.vt_value}",
      "description": "TestProp's <vt:{type.vt_element}> must carry the expected literal text."
    }
  ]
}