我正在使用NPOI 2.0.6.0,我正在尝试定位一个单元格VerticalAlign TOP和Center。
this._rowStyleLight.BorderRight = BorderStyle.Thin;
this._rowStyleLight.FillPattern = FillPattern.SolidForeground;
this._rowStyleLight.SetFillForegroundColor(this._rowColourLight);
this._rowStyleLight.VerticalAlignment = VerticalAlignment.Top;
VerticalAlignment不提供此功能。当我将_rowStyleLight.Alignment = HorizontalAlignment.Center;
设置为中心时,似乎NPOI不能同时应用两者。
有人可以帮忙吗?
答案 0 :(得分:1)
试试这个
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);