excel样式

optimize
wet 2 years ago
parent ad0b5984c8
commit 35246de5fa

@ -1817,8 +1817,6 @@ namespace Myshipping.Application
throw Oops.Bah("当前模板未设置");
}
//单元格样式
var cellStyle = NpoiExcelExportHelper._.CreateStyle(excelwork, HorizontalAlignment.Center, VerticalAlignment.Center, 10, true, 0);
for (int _row = 0; _row < entity.Max(x => x.Row); _row++)
{
@ -1837,7 +1835,8 @@ namespace Myshipping.Application
if (name == _name)
{
var value = descriptor.GetValue(order).ToString();
var cell = NpoiExcelExportHelper._.CreateCells(row, cellStyle, _cellNum, value);
var cell = NpoiExcelExportHelper._.CreateCells(row, _cellNum, value);
}
}
}

@ -37,10 +37,12 @@ namespace Myshipping.Core.Helper
/// <param name="cellNum">创建第几个单元格(从0开始)</param>
/// <param name="cellValue">给单元格赋值</param>
/// <returns></returns>
public HSSFCell CreateCells(HSSFRow row, HSSFCellStyle cellStyle, int cellNum, string cellValue)
public HSSFCell CreateCells(HSSFRow row, int cellNum, string cellValue, HSSFCellStyle cellStyle=null)
{
HSSFCell cell = (HSSFCell)row.CreateCell(cellNum); //创建单元格
cell.CellStyle = cellStyle; //将样式绑定到单元格
if (cellStyle!=null) {
cell.CellStyle = cellStyle; //将样式绑定到单元格
}
if (!string.IsNullOrWhiteSpace(cellValue))
{
//单元格赋值

Loading…
Cancel
Save