private void LoadData() { try { selectItems = dataReport.GetBudgetReportData(new BaseParam()); AdjustAllName(selectItems); dataTable = CommonHelper.ToDataTable(selectItems); var date = DateTime.Now; //selects.Add(new Company() //{ // Id = 0, // Name = "无" //}); for (int i = 0; i < selectItems.Count; i++) { var year = selectItems[i].Year == 0 ? date.Year : selectItems[i].Year; var month = selectItems[i].Month == 0 ? date.Month : selectItems[i].Month; selects.Add(new Company() { Id = i + 1, Name = $"{selectItems[i].CompanyName}{year}年{month}月预算表" }); } comboBox1.DataSource = selects; comboBox1.DisplayMember = "Name"; PushInExcel(dataTable); } catch (Exception e) { Console.WriteLine(e); } }
private void LoadReportData() { try { ClearRange(); var budgetReportDatas = reportLogic.GetBudgetReportData(reportParam); var dataTable = CommonHelper.ToDataTable(budgetReportDatas); sheet.SetRangeData(new RangePosition(3, 0, dataTable.Rows.Count, dataTable.Columns.Count), dataTable); } catch (Exception exception) { MessageBox.Show("查询失败!", "Error", MessageBoxButtons.OK); } }