我的需求:增加行的操作,在表格数据的最后增加一空行,并默认当前用户所在的部门,当你默认部门的时候有"下拉例表框"可以让你选择其他部门。
下面是我遇到的两个问题
下面是我的代码
/// <summary>
/// 增加行
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAddSpRow_Click(object sender, EventArgs e)
{
// 增加行自适应高度
this.CompanyBudgetFpSpread.Height = new Unit(this.CompanyBudgetFpSpread.Height.Value + Convert.ToDouble(21));
int maxCount = this.CompanyBudgetFpSpread.Sheets[0].RowCount;
this.CompanyBudgetFpSpread.Sheets[0].AddRows(maxCount, 1);
DataSet ds=new DataSet();
// 获取有数据的行数
int RowCount = this.CompanyBudgetFpSpread.Sheets[0].NonEmptyRowCount;
if(RowCount>0)
{
string ouName = Model.ModuleUtil.GetOUName(this.CurrentUser.LoginID);
//获取经办人所属部门
FarPoint.Web.Spread.ComboBoxCellType cmbocell1 = new FarPoint.Web.Spread.ComboBoxCellType();
cmbocell1.DataSource = SXT.ZHLC.Management.Model.OrgOU.RetSetOUData(this.SiteID,"","");
cmbocell1.DataTextField = "OUName";
cmbocell1.DataValueField = "OUID";
CompanyBudgetFpSpread.ActiveSheetView.Cells[maxCount, 1].CellType = cmbocell1;
// 设置年度
FarPoint.Web.Spread.ComboBoxCellType cmbocell2 = new FarPoint.Web.Spread.ComboBoxCellType();
cmbocell2.Items = (new String[] { "2014", "2015", "2016", "2017", "2018", "2019","2020","2021","2022","2023","2024","2025"});
CompanyBudgetFpSpread.ActiveSheetView.Cells[maxCount, 5].CellType = cmbocell2;
this.CompanyBudgetFpSpread.ActiveSheetView.Cells[maxCount, 1].Text = ouName;
this.CompanyBudgetFpSpread.ActiveSheetView.Cells[maxCount, 5].Text = DateTime.Now.Year.ToString();
}
this.CompanyBudgetFpSpread.SaveChanges();
} |
|