Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EPPlus row height size different

Tags:

c#

epplus

I am creating and filling an excel file from a table in my app. Once it's done, some rows do not have the same height than some others. There is no difference between the data. I can not figure it out.

You can see in the pic' the rows with blue stars and green stars do not have the same height.

enter image description here

I want them all have the green star height.

using (ExcelPackage package = new ExcelPackage(streamDest, streamTemp))
{

ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
    worksheet.DefaultRowHeight = 14.25;

for (...)
{
    if (...)
    {
        if (...)
        {
            AddExcelRow(worksheet, currentPosition, lstFlightsDisplayed[i]);
            currentPosition++;
        }
        else
        {
            worksheet.InsertRow(currentPosition, 1, startPos);
            worksheet.Row(i).Height = 14.25;
            worksheet.DefaultRowHeight = 14.25;
            AddExcelRow(worksheet, currentPosition, lstFlightsDisplayed[i]);
            currentPosition++;
        }
    }
}
}

I tried to use :

worksheet.Row(i).Height = 14.25;
worksheet.DefaultRowHeight = 14.25;

But it does not work. Do you have any ideas ? Thank you.

like image 216
Majestic Avatar asked Mar 22 '16 07:03

Majestic


1 Answers

Perhaps your data contains a newline in the beginning. You can try to disable WrapText:

for(int i = 1; i <= sheet.Dimension.End.Column; i++)
   sheet.column(i).Style.WrapText = false;
like image 52
Alexander Derck Avatar answered Sep 18 '22 15:09

Alexander Derck