private void InsertCommonColumns() { reportGridView.SettingsBehavior.AllowSort = true; reportGridView.InsertRightAlignedDataColumn("CustomerNumber", "#"); reportGridView.InsertHyperlinkColumn("CustomerName", "Customer", "Id", LinkHelper.NavigateUrlFormatToDashboardForCustomer); reportGridView.InsertCurrencyColumn("CurrentBalance", "Current"); reportGridView.InsertCurrencyColumn("MonthOldBalance", "Month 1"); reportGridView.InsertCurrencyColumn("TwoMonthsOldBalance", "Month 2"); reportGridView.InsertCurrencyColumn("ThreeMonthsOrOlderBalance", "Month 3+"); reportGridView.InsertCurrencyColumn("Balance"); reportGridView.InsertDataColumn("NextCallDate", "Next Call"); reportGridView.InsertMemoColumn("Note", "Note"); reportGridView.Columns["Note"].Visible = false; if (isReportWithNotes) { reportGridView.Columns["Note"].Visible = true; IsReportWithNotesLiteral.Text = "true"; IsReportWithNotesLiteral.Visible = false; } reportGridView.SettingsBehavior.ProcessFocusedRowChangedOnServer = false; reportGridView.SettingsBehavior.ProcessSelectionChangedOnServer = false; reportGridView.EnableCallBacks = true; reportGridView.SettingsDetail.ShowDetailRow = false; reportGridView.SettingsDetail.ShowDetailButtons = false; reportGridView.InsertDataColumn("Email"); reportGridView.InsertDataColumn("Contact"); reportGridView.InsertDataColumn("Phone"); reportGridView.InsertDataColumn("Cell", "Mobile Phone"); reportGridView.TotalSummary.Clear(); reportGridView.InsertTotalSummaryLabelColumn(0); reportGridView.InsertTotalSummarySumColumn("CurrentBalance"); reportGridView.InsertTotalSummarySumColumn("MonthOldBalance"); reportGridView.InsertTotalSummarySumColumn("TwoMonthsOldBalance"); reportGridView.InsertTotalSummarySumColumn("ThreeMonthsOrOlderBalance"); reportGridView.InsertTotalSummarySumColumn("Balance"); }
public override void Export() { AgedBalancesReport report = ViewState["AgedBalancesReport"] as AgedBalancesReport; System.Collections.Generic.IList <AgedBalancesReportRecord> exportRecordWithNotes = new System.Collections.Generic.List <AgedBalancesReportRecord>(); foreach (AgedBalancesReportRecord rptRecord in report.Records) { System.Collections.Generic.IList <CustomerNote> cnList = rptRecord.CustNoteList; rptRecord.Note = ""; foreach (CustomerNote cNote in cnList) { if (!string.IsNullOrEmpty(cNote.Comment)) { rptRecord.Note += "[" + cNote.CreatedByEmployeeName + "][" + cNote.Created.ToShortDateString() + "]"; rptRecord.Note += cNote.Comment + System.Environment.NewLine; } } if (!string.IsNullOrEmpty(rptRecord.Note)) { rptRecord.CustNoteList.Clear(); } exportRecordWithNotes.Add(rptRecord); } //init columns CffGridView exportGrid = new CffGridView(250); if (IsReportWithNotesLiteral.Text.ToLower() == "true") { exportGrid.SettingsBehavior.AllowSort = true; exportGrid.InsertRightAlignedDataColumn("CustomerNumber", "#"); exportGrid.InsertHyperlinkColumn("CustomerName", "Customer", "Id", LinkHelper.NavigateUrlFormatToDashboardForCustomer); exportGrid.InsertCurrencyColumn("CurrentBalance", "Current"); exportGrid.InsertCurrencyColumn("MonthOldBalance", "Month 1"); exportGrid.InsertCurrencyColumn("TwoMonthsOldBalance", "Month 2"); exportGrid.InsertCurrencyColumn("ThreeMonthsOrOlderBalance", "Month 3+"); exportGrid.InsertCurrencyColumn("Balance"); exportGrid.InsertDataColumn("NextCallDate", "Next Call"); exportGrid.InsertMemoColumn("Note", "Note"); exportGrid.Visible = false; exportGrid.InsertDataColumn("Email"); exportGrid.InsertDataColumn("Contact"); exportGrid.InsertDataColumn("Phone"); exportGrid.InsertDataColumn("Cell", "Mobile Phone"); exportGrid.TotalSummary.Clear(); exportGrid.InsertTotalSummaryLabelColumn(0); exportGrid.InsertTotalSummarySumColumn("CurrentBalance"); exportGrid.InsertTotalSummarySumColumn("MonthOldBalance"); exportGrid.InsertTotalSummarySumColumn("TwoMonthsOldBalance"); exportGrid.InsertTotalSummarySumColumn("ThreeMonthsOrOlderBalance"); exportGrid.InsertTotalSummarySumColumn("Balance"); exportGrid.DataSource = exportRecordWithNotes; exportGrid.DataBind(); } if (report != null) { ExcelDocument document = new ExcelDocument(); document.HSFFGetSheet.SetColumnWidth(8, 400); document.WriteTitle(report.Title); Hashtable hashtable = new Hashtable(); hashtable.Add("Client", "ClientName"); hashtable.Add("Customer", "CustomerName"); if (IsReportWithNotesLiteral.Text.ToLower() == "true") { exportGrid.WriteToExcelDocumentWithReplaceField(document, hashtable); } else { reportGridView.WriteToExcelDocumentWithReplaceField(document, hashtable); } document.MoveToNextRow(); document.MoveToNextRow(); document.AddCell("Date Viewed"); document.AddCell(report.DateViewed.ToDateTimeString()); WriteToResponse(document.WriteToStream(), report.ExportFileName); } }