Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Fri Oct 08, 2021 8:09 am

Hi.
When saving to pdf in Excel, converted file is rendered as expected.
When using Spire xls, as space between characters are bigger some texts do not fit in cells. How can we avoid this problem?

damsdams
 
Posts: 1
Joined: Fri Jul 16, 2021 11:59 am

Fri Oct 08, 2021 9:51 am

Hello,

Thank you for your inquiry.
Our Spire.XLS provides AutoFitColumns() and AutoFitRows() methods to autofit column width and row height according to the cell content. And we also provide the IsWrapText property to wrap long text. Please have a try. If these do not meet your needs, please provide your input Excel file and expected effect to help us do further investigation. You could attach them here or send them to us via email (support@e-iceblue.com). Thanks in advance.
Code: Select all
Workbook workbook = new Workbook();
workbook.LoadFromFile("text.xlsx");
//Get first worksheet of the workbook
Worksheet worksheet = workbook.Worksheets[0];
//Get cell A1 
CellRange cell = worksheet.Range["A1"];
//Autofit column width and row height based on cell value
cell.AutoFitColumns();
cell.AutoFitRows();

//Wrap text
CellRange cell2 = worksheet.Range["A2"];                 
cell2.IsWrapText = true;
...

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Thu Oct 14, 2021 9:10 am

Hello,

Hope you're doing well!
How is your issue going? Did the code we provided work for you? Any feedback will be greatly appreciated.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS