Exemple #1
0
        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);
            }
        }