我知道启始行号、列号,如何给其中的单元格,一次性赋属性值,就是背景颜色,边框什么的,我现在用的是循环,效率比较慢
for (int sheet = 0; sheet < this.fspMain.Sheets.Count; sheet++)//表单
{
_reportSize = lstReportSize.FindLast(obj => obj.RSheet == sheet);
//if (dateTimeSpan > _reportSize.RSheetRecordsRows)
//{
// MessageBox.Show("时间跨度不能大于当前页允许的最大记录数" + _reportSize.RSheetRecordsRows.ToString());
// return;
//}
this.fspMain.Sheets[sheet].RowCount = _reportSize.RRowCount + dateTimeSpan + 1;
if (dateTimeSpan > 0)
{
//this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount, 0, this.fspMain.Sheets[sheet].Rows.Count - 1, 0].BackColor = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, 0].BackColor;
//this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount, 0, this.fspMain.Sheets[sheet].Rows.Count - 1, 0].Border = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, 0].Border;
//this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount, 0, this.fspMain.Sheets[sheet].Rows.Count - 1, 0].Font = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, 0].Font;
this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount, 0, this.fspMain.Sheets[sheet].Rows.Count - 1, 0].CellType = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, 0].CellType;
//this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount, 0, this.fspMain.Sheets[sheet].Rows.Count - 1, 0].HorizontalAlignment = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, 0].HorizontalAlignment;
//this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount, 0, this.fspMain.Sheets[sheet].Rows.Count - 1, 0].VerticalAlignment = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, 0].VerticalAlignment;
//curProgressBar.Visible = true;
//curProgressBar.Value = 0;
//curProgressBar.Maximum = this.fspMain.Sheets[sheet].ColumnCount + 1;
for (int i = 1; i < this.fspMain.Sheets[sheet].ColumnCount; i++)
{
//curProgressBar.Value = curProgressBar.Value + 1;
//this.fspMain.Sheets[sheet].Columns.BackColor = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, i].BackColor;
//this.fspMain.Sheets[sheet].Columns.Border = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, i].Border;
//this.fspMain.Sheets[sheet].Columns.Font = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, i].Font;
//this.fspMain.Sheets[sheet].Columns.CellType = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, i].CellType;
//this.fspMain.Sheets[sheet].Columns.HorizontalAlignment = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, i].HorizontalAlignment;
//this.fspMain.Sheets[sheet].Columns.VerticalAlignment = this.fspMain.Sheets[sheet].Cells[_reportSize.RRowCount - 1, i].VerticalAlignment;
}
this.fspMain.Sheets[sheet].Rows[_reportSize.RRowCount, this.fspMain.Sheets[sheet].Rows.Count - 1].Locked = true;
//curProgressBar.Visible = false;
}
} |
|