Get Text Width of Cell Value
Contents
[
Hide
]
Get Text Width of Cell Value
Sometimes, the developers might need to calculate the width of the cell’s value for arranging data in some layout. Aspose.Cells provides the CellsHelper.GetTextWidth method which allows developers to get the text width of the cell’s value. The following sample code illustrates how to use CellsHelper.GetTextWidth to access the text width of the cell’s value.
The Source file used in the following code snippet is attached for your reference.
Sample Code
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
Workbook workbook = new Workbook(sourceDir + "GetTextWidthSample.xlsx"); | |
Console.WriteLine("Text width: " + CellsHelper.GetTextWidth(workbook.Worksheets[0].Cells["A1"].StringValue, workbook.DefaultStyle.Font, 1)); |