Python.NETを使った日付の日本式変換

Contents
[ ]

Aspose.Cellsは、西暦の日付を元号の変化を考慮して日本の元号日付に変換する方法を提供します。以下のコードスニペットは、西暦の日付を含むExcelファイルを日本の元号日付に変換し、PDFに出力する例です。

todo:image_alt_text

import os
from aspose.cells import Workbook, LoadOptions, LoadFormat, SaveFormat, CountryCode

# Source directory
current_dir = os.path.dirname(os.path.abspath(__file__))
source_dir = os.path.join(current_dir, "data")
output_dir = os.path.join(current_dir, "output")

# Create output directory if not exists
if not os.path.exists(output_dir):
    os.makedirs(output_dir)

# Initialize load options with XLSX format
options = LoadOptions(LoadFormat.XLSX)
options.region = CountryCode.JAPAN

# Load workbook with Japanese regional settings
workbook = Workbook(os.path.join(source_dir, "JapaneseDates.xlsx"), options)

# Save as PDF
workbook.save(os.path.join(output_dir, "JapaneseDates.pdf"), SaveFormat.PDF)

Python.NET変換:

注意:正確な元号変換のためには、お使いの環境で日本語サポートを有効にしてください。Workbook クラスと PdfSaveOptions はこの変換に必要な機能を提供します。