出力PDFと画像の文字列の交差方法を指定
Contents
[
Hide
]
考えられる使用シナリオ
セルにテキストまたは文字列が含まれているが、セルの幅よりも大きい場合、次の列の次のセルが null または空の場合、文字列はオーバーフローします。 Excel ファイルを PDF/Image に保存する場合、TextCrossType列挙。次の値があります。
-
TextCrossType.Default: 次のセルに依存する MS Excel のようなテキストを表示します。次のセルが null の場合、文字列が交差するか、切り捨てられます。
-
TextCrossType.CrossKeep: MS Excel exporting PDF/Image のような文字列を表示します
-
TextCrossType.CrossOverride: 他のセルと交差してすべてのテキストを表示し、交差したセルのテキストを上書きします
-
TextCrossType.StrictInCell: セルの幅内に文字列のみを表示します。
TextCrossType を使用して、出力 PDF/Image で文字列を交差させる方法を指定します
次のサンプル コードは、サンプルの Excel ファイルを読み込み、別のファイルを指定して PDF/Image 形式で保存します。TextCrossType.サンプルの Excel ファイルと出力ファイルは、次のリンクからダウンロードできます。
サンプルコード
This file contains 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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Load template Excel file | |
Workbook wb = new Workbook(sourceDir + "sampleCrosssType.xlsx"); | |
// Create file streams for saving the PDF and PNG files | |
using (FileStream outputStream = new FileStream(outputDir + "outputCrosssType.pdf", FileMode.Create)) | |
using (FileStream outputStream2 = new FileStream(outputDir + "outputCrosssType.png", FileMode.Create)) | |
{ | |
// Initialize PDF save options | |
PdfSaveOptions saveOptions = new PdfSaveOptions(); | |
// Set text cross type | |
saveOptions.TextCrossType = TextCrossType.StrictInCell; | |
// Save PDF file | |
wb.Save(outputStream, saveOptions); | |
// Initialize image or print options | |
ImageOrPrintOptions imageSaveOptions = new ImageOrPrintOptions(); | |
// Set text cross type | |
imageSaveOptions.TextCrossType = TextCrossType.StrictInCell; | |
// Initialize sheet renderer object | |
SheetRender sheetRenderer = new SheetRender(wb.Worksheets[0], imageSaveOptions); | |
// Create bitmap image from sheet renderer | |
System.Drawing.Bitmap bitmap = sheetRenderer.ToImage(0); | |
// Save PNG image | |
bitmap.Save(outputStream2, ImageFormat.Png); | |
} |