/// <summary> /// 解决合并后的单元格没有边框,设置合并单元格格式,让合并过的单元格中每一个单元格上都添加上加边框的样式 /// </summary> /// <param name="cells">单元格</param> /// <param name="firstRow">起始行</param> /// <param name="firstColumn">起始列</param> /// <param name="rowNumber">行偏移量</param> /// <param name="columnNumber">列偏移量</param> /// <param name="style">样式</param> private void SetCellStyle(Cells cells, int firstRow, int firstColumn, int rowNumber, int columnNumber, Style style) { int totalRow = firstRow + rowNumber; int totalColumn = firstColumn + columnNumber; for (int i = firstRow; i < totalRow; i++) { for (int j = firstColumn; j < totalColumn; j++) { cells[i, j].Style = style; } } }