我是给spread每个单元格赋值
for (int sheet = 0; sheet < this.fspMain.Sheets.Count; sheet++)
{
for (int row = 0; row < this.fspMain.Sheets[sheet].Rows.Count; row++)
{
curProgressBar.Value = curProgressBar.Value + 1;
Application.DoEvents();
List<ReportIndexEntity> lstRIE = new List<ReportIndexEntity>();
lstRIE = _listReportIndex.FindAll(obj => obj.Sheet == sheet && obj.CellRow == row && this.fspMain.Sheets[obj.Sheet].Cells[obj.CellRow, obj.CellColumn].Text == "" && obj.DataSourceFunction != null && obj.DataSourceFunction != "" && obj.BegDateTimeFunction != null && obj.BegDateTimeFunction != "" && obj.DataSourceFunction != null && obj.DataSourceFunction != "");
lstSQL = "";
foreach (ReportIndexEntity ri in lstRIE) //遍历所有单元格配置信息列表
{
try
{
sql = new GetDataSourceSQLBll().GetAllCellSQLString(ri, ucReportDateTime.SelectDateTimeBeg, MenuId);
}
catch
{
sql = null;
}
if (sql != null && sql != "")
{
if (lstSQL != "")
{
lstSQL = lstSQL + "UNION ALL(" + sql + ")";
}
else
{
lstSQL = "(" + sql + ")";
}
}
}
if (lstSQL != "")
{
try
{
lstReportCellDataEntity = refreshDatabll.RefreshDatas(lstSQL);
foreach (ReportCellDataEntity rcde in lstReportCellDataEntity)
{
try
{
if (Convert.ToDouble(rcde.IndexData) == 0)
{
this.fspMain.Sheets[rcde.Sheet].Cells[rcde.CellRow, rcde.CellColumn].Text = null;
}
else
{
this.fspMain.Sheets[rcde.Sheet].Cells[rcde.CellRow, rcde.CellColumn].Text = rcde.IndexData;
}
}
catch
{
this.fspMain.Sheets[rcde.Sheet].Cells[rcde.CellRow, rcde.CellColumn].Text = rcde.IndexData;
}
}
}
catch
{
//MessageBox.Show(sheet.ToString() + "页," + row.ToString() + "行,记录指标配置存在错误,请配置指标人员仔细查检后,修正错误配置!");
}
}
}
} |
|