【问题标题】:NPOI Vertical align and CenterNPOI 垂直对齐和居中
【发布时间】:2017-07-24 22:59:06
【问题描述】:

我正在使用 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; 也设置为 Center 时,似乎 NPOI 不能同时应用两者。

有人可以帮忙吗?

【问题讨论】:

    标签: c# excel interop npoi


    【解决方案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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-10
      • 2012-10-09
      相关资源
      最近更新 更多