CR41G14
CR41G14

Reputation: 5594

NPOI Vertical align and Center

I am using the NPOI 2.0.6.0 and I am trying to position a cell VerticalAlign TOP and Center.

this._rowStyleLight.BorderRight = BorderStyle.Thin;
this._rowStyleLight.FillPattern = FillPattern.SolidForeground;
this._rowStyleLight.SetFillForegroundColor(this._rowColourLight);
this._rowStyleLight.VerticalAlignment = VerticalAlignment.Top;

The VerticalAlignment doesn't offer this. When I set the _rowStyleLight.Alignment = HorizontalAlignment.Center; to be Center too then it seems as if NPOI cannot apply both.

Can anyone assist?

Upvotes: 2

Views: 2525

Answers (1)

kumar chandraketu
kumar chandraketu

Reputation: 2370

try this

XSSFFont yourFont = (XSSFFont)workbook.CreateFont();
yourFont.FontHeightInPoints = (short)10;
yourFont.FontName = "Arial";

XSSFCellStyle yourStyle = (XSSFCellStyle)workbook.CreateCellStyle();
yourStyle.WrapText = true;
yourStyle.Alignment = HorizontalAlignment.Left;
yourStyle.VerticalAlignment = VerticalAlignment.Top;
yourStyle.BorderBottom = BorderStyle.Thin; 
yourStyle.SetFont(yourFont);

sheet.SetyourColumnStyle(col, yourStyle);

Upvotes: 2

Related Questions