Wraptext = true problem

Aug 8, 2012 at 2:28 PM
Edited Aug 8, 2012 at 2:30 PM

Hello everyone. I'm generating an excel report through EPPLUS and there's one column that is particularly big (lots of words) and i'd like to after some words inside the cell, add a line break for a better legibility. I've searched a bit and i've came across this property wraptext.

But, instead of something like this:

"This is some random text inside a cell.

It was supposed to go like this."

it goes like this:

"This

is

some

random

text

inside

a

cell"

 

Any solutions for this one? (i'm using the latest epplus version)

Editor
Aug 17, 2012 at 1:08 PM

Wraptext property will not resize your column, maybe your column is really tight.

http://i.imgur.com/4qtEm.png ( code below will produce this excel )

 

            using (ExcelPackage p = new ExcelPackage(new FileInfo(@"c:\test.xlsx")))
            {

                var w = p.Workbook.Worksheets.Add("test");

                w.Column(1).Width = 10;
                w.Column(2).Width = 15;
                w.Column(3).Width = 20;
                w.Column(3).Width = 30;

                w.Cells[1, 1].Value = "This is a random text inside cell.";
                w.Cells[1, 2].Value = "This is a random text inside cell.";
                w.Cells[1, 3].Value = "This is a random text inside cell.";
                w.Cells[1, 4].Value = "This is a random text inside cell.";

                w.Cells[1, 1].Style.WrapText = true;
                w.Cells[1, 2].Style.WrapText = true;
                w.Cells[1, 3].Style.WrapText = true;
                w.Cells[1, 4].Style.WrapText = true;


                p.Save();

            }

Jan 22, 2015 at 4:44 AM
How do we compute the cell width?

Is it computed based on the font size, as well as the text width?