出力PDFおよびイメージで文字列をクロスする方法を指定します。
Contents
[
Hide
]
出力PDFおよび画像内の文字列の交差方法を指定
セルに文字列がセルの幅よりも大きい場合、次の列のセルがnullまたは空である場合、文字列がオーバーフローします。ExcelファイルをPDF/Imageに保存するときには、TextCrossType 列挙型を使用してこのオーバーフローを制御できます。
- TextCrossType.DEFAULT:MS Excelの表示に従い、次のセルに依存します。次のセルがnullの場合、文字列がクロスされるか切り取られます。
- TextCrossType.CROSS_KEEP:MS Excelのエクスポートと類似した方法で文字列を表示
- TextCrossType.CROSS_OVERRIDE:他のセルをクロスして文字列をオーバーライドしてすべてのテキストを表示
- TextCrossType.STRICT_IN_CELL:セルの幅内で文字列を表示
次のサンプルコードは、サンプルExcelファイルをロードし、異なるTextCrossTypeを指定してPDF/Image形式で保存します。サンプルExcelファイルと出力ファイルは、以下のリンクからダウンロードできます。
サンプルコード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
output_directory = "Examples/SampleFiles/OutputDirectory/" | |
# Load the Sample Workbook | |
workbook = Workbook(source_directory + "sampleCrossType.xlsx") | |
# Initialize PDF save options | |
saveOptions = PdfSaveOptions() | |
# Set text cross type | |
saveOptions.setTextCrossType(TextCrossType.STRICT_IN_CELL) | |
# Save the excel file. | |
workbook.save(output_directory + "outputCrossType.pdf") |