private void FillBody() { #region Styles var borderId = _openXMLExcel.GetBorderId(BorderStyleValues.Thin, DColor.Black); var fontId = _openXMLExcel.GetFontId(12, "宋体", DColor.Black); var alignment = new Alignment() { Horizontal = HorizontalAlignmentValues.Center, Vertical = VerticalAlignmentValues.Center }; var cellFormatIndex = _openXMLExcel.GetCellFormatIndex( borderId, fontId, alignment: alignment); var cornerCellFormatIndex = _openXMLExcel.GetCellFormatIndex( borderId: _openXMLExcel.GetBorderId(BorderStyleValues.Thin, DColor.Black, true), alignment: new Alignment() { Vertical = VerticalAlignmentValues.Top, WrapText = true }); var numberingCellFormatIndex = _openXMLExcel.GetCellFormatIndex( borderId, fontId, numberFormatId: _openXMLExcel.GetNumberingFormatId("0.0%"), alignment: alignment.CloneSafely()); #endregion var row1 = new Row() { RowIndex = _rowIndex++, Height = 27, CustomHeight = true }; //S: Row _writer.WriteStartElement(row1); _writer.WriteElement(new Cell() { CellReference = $"A{ row1.RowIndex }", StyleIndex = cellFormatIndex, CellValue = new CellValue() { Text = "序号" } }); _writer.WriteElement(new Cell() { CellReference = $"B{ row1.RowIndex }", StyleIndex = cornerCellFormatIndex, CellValue = new CellValue() { Text = new string(' ', (int)ColumnBWidth - 10) + "频段(MHz)\n地区" } }); _writer.WriteElement(new Cell() { CellReference = $"C{ row1.RowIndex }", StyleIndex = cellFormatIndex, CellValue = new CellValue() { Text = "223-235" } }); _writer.WriteElement(new Cell() { CellReference = $"D{ row1.RowIndex }", StyleIndex = cellFormatIndex, CellValue = new CellValue() { Text = "351-399.9" } }); //E: Row _writer.WriteEndElement(); for (int i = 1; i <= 3; i++) { var row = new Row() { RowIndex = _rowIndex++, Height = 14.25, CustomHeight = true }; //S: Row _writer.WriteStartElement(row); _writer.WriteElement(new Cell() { CellReference = $"A{ row.RowIndex }", StyleIndex = cellFormatIndex, CellValue = new CellValue() { Text = i.ToString() }, DataType = CellValues.Number }); _writer.WriteElement(new Cell() { CellReference = $"B{ row.RowIndex }", StyleIndex = cellFormatIndex, CellValue = new CellValue() { Text = $"监测站{i}" } }); _writer.WriteElement(new Cell() { CellReference = $"C{ row.RowIndex }", StyleIndex = numberingCellFormatIndex, CellValue = new CellValue() { Text = $"0.1{i}" }, DataType = CellValues.Number }); _writer.WriteElement(new Cell() { CellReference = $"D{ row.RowIndex }", StyleIndex = numberingCellFormatIndex, CellValue = new CellValue() { Text = $"0.2{i}" }, DataType = CellValues.Number }); //E: Row _writer.WriteEndElement(); } }