protected void btnExportToExcel_Click(object sender, EventArgs e) { SalesRepresentativeReportingChild obj = new SalesRepresentativeReportingChild(); DataSet ds = obj.GetSKPickingBoard2("Select One", "Select One", "Select One", "Select One", "Select One", "Select One", "Select One");//, "Select One"); WorkbookEngine we = new WorkbookEngine(); we.ExportDataSetToExcel(ds.Tables[0], "Sales Representative Reporting"); }
protected void btnexcelDownload_Click(object sender, EventArgs e) { ModalPopupExtender2.Hide(); BusinessUnitReportingChild obj = new BusinessUnitReportingChild(); DataSet ds = obj.GetSKPickingBoard2("Select One", "Select One", "Select One"); WorkbookEngine we = new WorkbookEngine(); foreach (DataRow dr in ds.Tables[0].Rows) { if (!dr.IsNull("ExpirationDate")) { dr.Delete(); } //DateTime expirationDate = Convert.ToDateTime(dr["ExpirationDate"].ToString()); } we.ExportDataSetToExcel(ds.Tables[0], "BusinessUnit Reporting"); }
public static void CreateWorkbook(DataSet ds, String path) { try { if (ds.Tables.Count > 0) { WorkbookEngine we = new WorkbookEngine(); we.CreateWorkbook(ds); we.SaveWorkbook(path); } } catch (Exception e) { IntegratorBatch.ExceptionLogger.Fatal("Impossible de créer le fichier Excel:" + path, e); throw e; } }
private void btnExportar_Click(object sender, EventArgs e) { if (dataSet1.Tables.Count == 0) { MessageBox.Show( "No hay datos en la sección de resultados. Realice una consulta antes de intentar exportar", "No se puede exportar", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (saveFileDialog1.ShowDialog() == DialogResult.OK) { try { var fs = new StreamWriter(saveFileDialog1.FileName); fs.Write(WorkbookEngine.CreateWorkbook(dataSet1)); fs.Close(); } catch (Exception ex) { Log.ShowAndLog(ex); } } }