6

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.

1
  • Yeah man it is working ! Could you write an answer I can validate ?
    – Majestic
    Mar 22, 2016 at 8:04

1 Answer 1

4

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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.