Save to PDF does not resize a cell to fit a wrapped text value as Excel does

Save to PDF does not resize a cell to fit a wrapped text value as Excel does. See C2 in the XLSX and PDF files produces by:

var workbook = new Workbook(GetFullPath(“sample.xlsx”));
var ws = workbook.Worksheets[0];
ws.Cells[“C2”].Value = @“kfdlasjf askljdf asdklfj asdflkjaslk. skajfkl sdkljaflkj askldjflk.”;
workbook.Save(GetFullPath(“result.xlsx”));
workbook.Save(GetFullPath(“result.pdf”), SaveFormat.Pdf);


Is it a bug? Is there a workaround to make Aspose to size rows before saving to PDF?

Hi,


Thanks for the template file, sample code and details.

Well, you need to extend the row’s height a bit, so the contents in the cell(s) should be displayed fine. It is better to use Worksheet.AutoFitRow/AutoFitRows method(s), see the sample code below, I only added a line to your code which works fine and as expected.
e.g
Sample code:

var workbook = new Workbook(GetFullPath(“sample.xlsx”));
var ws = workbook.Worksheets[0];
ws.Cells[“C2”].Value = @“kfdlasjf askljdf asdklfj asdflkjaslk. skajfkl sdkljaflkj askldjflk.”;
ws.AutoFitRow(1);//Auto-fit the second row height
workbook.Save(GetFullPath(“result.xlsx”));
workbook.Save(GetFullPath(“result.pdf”), SaveFormat.Pdf);


Hope, this helps a bit.

Thank you.

Thanks, that helped.

Hi,


Good to know that it helps you to figure your issue out. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.