Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
When a cell contains text or a string that is larger than the width of the cell, the string overflows if the next cell in the next column is null or empty. When you save your Excel file into PDF/Image, you can control this overflow by specifying the cross type using the TextCrossType enumeration. It has the following values:
TextCrossType.Default: Display text like MS Excel, which depends on the next cell. If the next cell is null, the string will cross, otherwise it will be truncated.
TextCrossType.CrossKeep: Display the string as MS Excel does when exporting to PDF/Image.
TextCrossType.CrossOverride: Display all the text by crossing other cells and overriding the text of crossed cells.
TextCrossType.StrictInCell: Only display the string within the width of the cell.
The following sample code loads the sample Excel file and saves it to PDF/Image format by specifying different TextCrossType. The sample Excel file and output files can be downloaded from the following links:
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const sourceDir = path.join(__dirname, "data");
const outputDir = path.join(__dirname, "output");
// Load template Excel file
const workbook = new AsposeCells.Workbook(path.join(sourceDir, "sampleCrossType.xlsx"));
// Initialize PDF save options
const pdfSaveOptions = new AsposeCells.PdfSaveOptions();
// Set text cross type
pdfSaveOptions.setTextCrossType(AsposeCells.TextCrossType.StrictInCell);
// Save PDF file
workbook.save(outputDir + "outputCrossType.pdf", pdfSaveOptions);
// Initialize image or print options
const imageSaveOptions = new AsposeCells.ImageOrPrintOptions();
// Set text cross type
imageSaveOptions.setTextCrossType(AsposeCells.TextCrossType.StrictInCell);
// Initialize sheet renderer object
const sheetRenderer = new AsposeCells.SheetRender(workbook.getWorksheets().get(0), imageSaveOptions);
sheetRenderer.toImage(0, outputDir + "outputCrossType.png");
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.