public override void PopulateData() { try { using (TaxiDataContext db = new TaxiDataContext()) { grdLister.DataSource = db.stp_DriverCommissionPaymentSummary(); grdLister.Columns["Id"].IsVisible = false; grdLister.Columns["LastStatementDate"].IsVisible = false; grdLister.Columns["DriverNo"].HeaderText = "Driver No"; grdLister.Columns["DriverName"].HeaderText = "Name"; grdLister.Columns["VehicleType"].HeaderText = "Vehicle Type"; grdLister.Columns["LastStatementNo"].IsVisible = false; //grdLister.Columns["LastStatementNo"].HeaderText = "Last Statement No"; grdLister.Columns["DriverName"].Width = 140; grdLister.Columns["CurrentBalance"].HeaderText = "C Balance"; grdLister.Columns["DriverNo"].Width = 140; grdLister.Columns["VehicleType"].Width = 140; grdLister.Columns["Owed"].Width = 100; grdLister.Columns["Paid"].Width = 100; grdLister.Columns["CurrentBalance"].Width = 150; } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void btnExport_Click(object sender, EventArgs e) { try { if (DialogResult.OK == saveFileDialog1.ShowDialog()) { if (radGridView1 == null) { InitializeExportGrid(); } radGridView1.Columns.Clear(); radGridView1.Columns.Add(new GridViewTextBoxColumn("DriverNo", "DriverNo")); radGridView1.Columns.Add(new GridViewTextBoxColumn("DriverName", "Name")); radGridView1.Columns.Add(new GridViewTextBoxColumn("VehicleType", "Vehicle")); radGridView1.Columns.Add(new GridViewTextBoxColumn("Owed", "Owed")); radGridView1.Columns.Add(new GridViewTextBoxColumn("Paid", "Paid")); radGridView1.Columns.Add(new GridViewTextBoxColumn("CurrentBalance", "C Balance")); //radGridView1.Columns.Add(new GridViewTextBoxColumn("Driver", "Driver")); //radGridView1.Columns.Add(new GridViewTextBoxColumn("Vehicle", "Vehicle")); //radGridView1.Columns.Add(new GridViewTextBoxColumn("Price", "Price")); using (TaxiDataContext db = new TaxiDataContext()) { var query = db.stp_DriverCommissionPaymentSummary().ToList(); radGridView1.RowCount = query.Count; for (int i = 0; i < query.Count; i++) { // radGridView1.Rows[i].Cells["PickupDate"].Value = " " + string.Format(" {0:dd/MM/yyyy HH:mm} ", query[i].PickupDate) + " "; radGridView1.Rows[i].Cells["DriverNo"].Value = query[i].DriverNo.Replace("=", "").Trim(); radGridView1.Rows[i].Cells["DriverName"].Value = query[i].DriverName.Replace("=", "").Trim(); radGridView1.Rows[i].Cells["VehicleType"].Value = query[i].VehicleType.Replace("=", "").Trim(); //radGridView1.Rows[i].Cells["Customer"].Value = query[i].Customer.Replace("=", "").Trim(); //radGridView1.Rows[i].Cells["Telephone"].Value = string.Format(" {0:F0} ", query[i].Telephone) + "."; //" " + string.Format(" {0:dd/MM/yyyy HH:mm} ", query[i].Telephone.Replace("=", "").Trim()) + " "; radGridView1.Rows[i].Cells["Owed"].Value = query[i].Owed; radGridView1.Rows[i].Cells["Paid"].Value = query[i].Paid; radGridView1.Rows[i].Cells["CurrentBalance"].Value = query[i].CurrentBalance; // radGridView1.Rows[i].Cells["Telephone"].ViewInfo.; //radGridView1.Rows[i].Cells["Telephone"].Value = (radGridView1.Rows[i].Cells["Telephone"].Value.ToString().Replace(".", "")); } } ExportToExcelML export = new ExportToExcelML(this.radGridView1); export.ExportVisualSettings = true; export.HiddenColumnOption = HiddenOption.ExportAsHidden; export.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport; export.ExcelCellFormatting += new Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventHandler(export_ExcelCellFormatting); // radGridView1.Columns["DriverNo"].HeaderText = "Driver No"; radGridView1.Columns["DriverName"].HeaderText = "Name"; radGridView1.Columns["VehicleType"].HeaderText = "Vehicle"; //grdLister.Columns["LastStatementNo"].HeaderText = "Last Statement No"; radGridView1.Columns["CurrentBalance"].HeaderText = "C Balance"; // //grdLister.Columns["PickupDate"].HeaderText = "Pickup Date-Time"; //radGridView1.Columns["From"].HeaderText = "Pick-up Address"; //radGridView1.Columns["To"].HeaderText = "Drop-off Address"; //radGridView1.Columns["CompanyName"].HeaderText = "Account"; //Me.RadGridView1.Columns(0).ExcelExportType = Export.DisplayFormatType.Text //CompanyName exporter = new RadGridViewExcelExporter(); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted); worker.RunWorkerAsync(saveFileDialog1.FileName); exporter.Progress += new ProgressHandler(exportProgress); this.btnExport.Enabled = false; } } catch (Exception ex) { } }