private void btnexport_Click(object sender, EventArgs e) { try { saveFileDialog1.Filter = "Excel File (*.xls)|*.xls|AdvExcel File (*.xlsx)|*.xlsx"; saveFileDialog1.Title = "Save File"; saveFileDialog1.FileName = "SageInvoice"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { PopulateGrid(); grdLister.Columns["InvoiceType"].Width = 70; grdLister.Columns["InvoiceType"].HeaderText = "invoice type"; grdLister.Columns["AccountCode"].Width = 70; grdLister.Columns["AccountCode"].HeaderText = "account code"; grdLister.Columns["SageNo"].Width = 50; grdLister.Columns["SageNo"].HeaderText = "sage no."; grdLister.Columns["BlankField"].HeaderText = ""; grdLister.Columns["InvoiceDate"].Width = 60; grdLister.Columns["InvoiceDate"].HeaderText = "invoice date"; grdLister.Columns["InvoiceNo"].Width = 70; grdLister.Columns["InvoiceNo"].HeaderText = "invoice npo."; grdLister.Columns["SoftwareName"].Width = 120; grdLister.Columns["SoftwareName"].HeaderText = "software name."; grdLister.Columns["InvoiceTotal"].Width = 70; grdLister.Columns["InvoiceTotal"].HeaderText = "invoice total"; grdLister.Columns["TaxCode"].Width = 50; grdLister.Columns["TaxCode"].HeaderText = "tax code"; grdLister.Columns["Vat"].Width = 40; grdLister.Columns["Vat"].HeaderText = "vat"; string heading = string.Empty; // heading = string.Format("{0:dd/MM/yyyy hh:mm tt}", dtF) + " till " + string.Format("{0:dd/MM/yyyy hh:mm tt}", dtT); ClsExportGridView obj = new ClsExportGridView(grdLister, saveFileDialog1.FileName); obj.ApplyCellFormatting = false; obj.ApplyCustomCellFormatting = true; // obj.Heading = heading; obj.ExportExcelAsync(); } } catch { } }
void btnExportXL_Click(object sender, EventArgs e) { if (grdDriverJobsList.Rows.Count == 0) { return; } try { saveFileDialog1.Filter = "Excel File (*.xls)|*.xls|AdvExcel File (*.xlsx)|*.xlsx"; saveFileDialog1.Title = "Save File"; saveFileDialog1.FileName = "Driver Booking Stats"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { //grdLister.Columns["IsPaid"].IsVisible = false; //grdLister.Columns["Paid"].IsVisible = true; ////grdLister.Columns["btnUpdate"].IsVisible = false; //grdLister.Columns[COLS.Active].Width = 50; //grdLister.Columns[COLS.Rent].Width = 60; //grdLister.Columns[COLS.DriverNo].Width = 50; //grdLister.Columns[COLS.PreviousBalance].Width = 85; //grdLister.Columns[COLS.Adjustment].Width = 60; //grdLister.Columns[COLS.Collection].Width = 60; //grdLister.Columns[COLS.AgentCommission].Width = 70; //grdLister.Columns[COLS.OldAgentBalance].Width = 90; //grdLister.Columns[COLS.Total].Width = 45; //grdLister.Columns[COLS.Paid].Width = 35; //var row = grdLister.Rows.OrderByDescending(c => c.Cells["ToDate"].Value.ToDate()).FirstOrDefault(); //DateTime? dtCurrent = row.Cells["FromDate"].Value.ToDate(); //DateTime dtEnd = row.Cells["ToDate"].Value.ToDate(); Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[1]; string heading = string.Empty; heading = "" + string.Format("from {0:dd/MM/yyyy}", dtpFromDate.Value) + " till " + string.Format("{0:dd/MM/yyyy}", dtpTillDate.Value); ClsExportGridView obj = new ClsExportGridView(grdDriverJobsList, saveFileDialog1.FileName); obj.ApplyCellFormatting = true; obj.ApplyCustomCellFormatting = true; obj.Heading = heading; obj.ExportExcelAsync(radProgressBar1); //obj.ConditionalFormattingObject = new StyleDataRowConditionalFormattingObject(); //obj.ConditionalFormattingObject.ConditionFormattingColumnName = "Paid"; //obj.ConditionalFormattingObject.RowBackColor = Color.LightGreen; //obj.ConditionalFormattingObject.RowForeColor = Color.Black; //obj.ConditionalFormattingObject.TValue = "Paid"; //if (obj.ExportExcel()) //{ // RadDesktopAlert alert = new RadDesktopAlert(); // alert.CaptionText = "Export"; // alert.ContentText = "<html> <b><span style=font-size:medium><color=Blue>Export Successfully</span></b></html>"; // alert.Show(); //} //grdLister.Columns["IsPaid"].IsVisible = true; //grdLister.Columns["Paid"].IsVisible = false; // grdLister.Columns["IsPaid"].IsVisible = false; // grdLister.Columns["Paid"].IsVisible = true; } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } finally { SetDefaultColumnSettings(); } }