private void buttonItem2_Click(object sender, EventArgs e) { CRClientesCompletos rptExcel = new CRClientesCompletos(); rptExcel.Load("CRClientesCompletos.rpt"); rptExcel.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; rptExcel.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString(); saveFileDialog.Filter = "Document (*.pdf)|*.pdf"; saveFileDialog.FilterIndex = 1; if (saveFileDialog.ShowDialog() == DialogResult.OK) { DiskFileDestinationOptions objOptions = new DiskFileDestinationOptions(); objOptions.DiskFileName = saveFileDialog.FileName; rptExcel.ExportOptions.ExportDestinationOptions = objOptions; rptExcel.Export(); objOptions = null; } rptExcel = null; }
private void btnImprimir_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); DataTable dt = new DataTable("Clientes"); // Columnas foreach (DataGridViewColumn column in dgvClientes.Columns) { DataColumn dc = new DataColumn(column.Name.ToString()); dt.Columns.Add(dc); } // Datos for (int i = 0; i < dgvClientes.Rows.Count; i++) { DataGridViewRow row = dgvClientes.Rows[i]; DataRow dr = dt.NewRow(); for (int j = 0; j < dgvClientes.Columns.Count; j++) { dr[j] = (row.Cells[j].Value == null) ? "" : row.Cells[j].Value.ToString(); } dt.Rows.Add(dr); } ds.Tables.Add(dt); ds.WriteXml("C:\\XML\\ClientesRPT.xml", XmlWriteMode.WriteSchema); //ExportOptions opciones = new ExportOptions(); //ExcelFormatOptions excelopc = new ExcelFormatOptions(); //excelopc.ExcelUseConstantColumnWidth = true; //opciones.ExportFormatOptions = excelopc; CRClientesCompletos rpt = new CRClientesCompletos(); frmClientesRP frm = new frmClientesRP(); rpt.SetDataSource(ds); frm.cRVClientesRP.ReportSource = rpt; frm.Show(); }
private void frmClientesRP_Load(object sender, EventArgs e) { if (Tipo == 1)//frmClientesCompletos { CRClientesCompletos CRep = new CRClientesCompletos(); CRep.Load("CRClientesCompletos.rpt"); CRep.SetDataSource(DTable); cRVClientesRP.ReportSource = CRep; } if (Tipo == 2)//frmClientesCorporativos { CRClientesCorporativos CRep = new CRClientesCorporativos(); CRep.Load("CRClientesCorporativos.rpt"); CRep.SetDataSource(DTable); cRVClientesRP.ReportSource = CRep; } if (Tipo == 3)//frmClientesSimples { CRClientesSimple CRep = new CRClientesSimple(); CRep.Load("CRClientesSimple.rpt"); CRep.SetDataSource(DTable); cRVClientesRP.ReportSource = CRep; } }