How to set the line height of an Excel in NPOI?

Asked

Viewed 197 times

0

I am trying to create a line in an excel file through the library NPOI. The problem is that I don’t know how to set a line size. Currently, the line is covering the text content.

How can I set the line height (if possible automatic line height)?

private static void CreateHeader(IRow row, List<string> header)
{

    HSSFWorkbook wb = new HSSFWorkbook();

    ISheet sheet = wb.CreateSheet("Modelo");

    ICellStyle style = wb.CreateCellStyle();

    IRow row = row.CreateRow(0);

    for (int i = 0; i < header.Count; i++)
    {
        ICell cell = row.CreateCell(i);

        cell.SetCellValue(header[i]);

        cell.CellStyle = style;
    }            
}
  • Have you tried using the RowHeight? In the case row.RowHeight = 50, for example, it wouldn’t work?

  • @Evert kkk, I didn’t think so, but I saw it has the attribute Height and HeightInPoint

1 answer

0


I discovered that there are two properties in IRow which allows the definition of line height:

IRow row = row.CreateRow(0);
row.Height = 10;
row.HeightInPoints = 20;

The error was happening when I tried to define through the row.RowStyle.Height.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.