Free Support Forum - aspose.com

Aspose.Cells text wrapping problems

Hello,

I can’t solve a problem with text wrapping using Aspose.Cells.
I’ve attached zip file containing example xls and pdf files.
I have to insert list of values to xls table. In the column named “Kontaktai” strings consisting of email, phone etc must be inserted. The string can be quite long so text in that columns cells has to be wrapped. The problem is that only values in first table row are wrapped. Text in every other inserted row is not wrapped. And if i convert that excel document to Pdf using Aspose.Pdf tool, I get the first row having incorrect height, but every other row is displayed correctly.
This is the part of code that fills xls worksheet column values:

Aspose.Cells.Range range = doc.Worksheets.GetRangeByName(pBinding.UniqueValue);
Worksheet worksheet = this.doc.Worksheets[range.Worksheet.Index];
Style style = worksheet.Cells[range.FirstRow, range.FirstColumn].Style;
CellArea area = new CellArea();
area.StartRow = range.FirstRow + 1;
area.StartColumn = range.FirstColumn;
area.EndColumn = range.FirstColumn; // I insert each column values individualy

worksheet.Cells.InsertRange(area,ShiftType.Down);
for ( int i = area.StartRow-1; i <= area.EndRow; i++)
{
Cell cell = worksheet.Cells[i, area.StartColumn];
cell.Style = style;
// put each value individualy not using ImportArray method. In that way excel formatting of values is preserved.
cell.PutValue(list[i - area.StartRow + 1]);
}

if (style.IsTextWrapped)
{
worksheet.AutoFitRow(area.StartRow, area.EndRow, area.StartColumn, area.EndColumn);
}

I need that both (excel and pdf) documents would be displaying wrapped text correctly
We are using Version 4.3.0.12 of Aspose.Cells and Version 3.5.2.0 of Aspose.Pdf

Thank you

Hi,

Thanks for considering Aspose.

Please try the latest version of Aspose.Cells (4.4) and also the latest version of Aspose.Pdf.

Thank you.

Hi,

Upgrading to the latest versions of Aspose.Cells and Aspose.Pdf didn’t solve the problem. I still get the same results

Hi,

Thanks for considering Aspose.

For text wrapping issue, please expand the row height to apply rext wrapping into the cells using Cells.SetRowHeight() method. And for convering excel 2 pdf issue please try the attached version.

Thank you.