void GenerarReporte() { if (app == null) app = new E.Application(); app.Visible = false; wb = app.Workbooks.Open(@rutas.RutaDeReportes + "\\facapt04.xlsx"); E.Worksheet ws = wb.Worksheets[1]; int index = 8; for (int i = dgvLista.SelectedRows.Count - 1; i >= 0 ; i--) { ws.Range["A" + index].Value2 = dgvLista.SelectedRows[i].Cells[1].Value.ToString(); ws.Range["B" + index].Value2 = dgvLista.SelectedRows[i].Cells[2].Value.ToString(); ws.Range["C" + index].Value2 = dgvLista.SelectedRows[i].Cells[3].Value.ToString(); ws.Range["D" + index].Value2 = dgvLista.SelectedRows[i].Cells[4].Value.ToString(); ws.Range["E" + index].Value2 = dgvLista.SelectedRows[i].Cells[5].Value.ToString(); ws.Range["F" + index].Value2 = dgvLista.SelectedRows[i].Cells[6].Value.ToString(); ws.Range["G" + index].Value2 = dgvLista.SelectedRows[i].Cells[7].Value.ToString(); ws.Range["H" + index].Value2 = dgvLista.SelectedRows[i].Cells[8].Value.ToString(); ws.Range["I" + index].Value2 = DateTime.Parse(dgvLista.SelectedRows[i].Cells[9].Value.ToString()).ToString("dd/MM/yyyy"); if (string.IsNullOrEmpty(dgvLista.SelectedRows[i].Cells[10].Value.ToString() ) || string.IsNullOrWhiteSpace(dgvLista.SelectedRows[i].Cells[10].Value.ToString())) ws.Range["J" + index].Value2 = string.Empty; else ws.Range["J" + index].Value2 = DateTime.Parse(dgvLista.SelectedRows[i].Cells[10].Value.ToString()).ToString("dd/MM/yyyy"); index++; } if (System.IO.File.Exists(System.IO.Path.GetTempPath() + "reporte.xlsx")) System.IO.File.Delete(System.IO.Path.GetTempPath() + "reporte.xlsx"); if (System.IO.File.Exists(@rutas.RutaDeTemp + "/rpt_ProdEmpacado.pdf")) System.IO.File.Delete(@rutas.RutaDeTemp + "/rpt_ProdEmpacado.pdf"); wb.SaveAs(System.IO.Path.GetTempPath() + "reporte.xlsx"); wb.ExportAsFixedFormat(E.XlFixedFormatType.xlTypePDF, @rutas.RutaDeTemp + "/rpt_ProdEmpacado.pdf"); VistasPrevias vp = new VistasPrevias(); vp.Navegar(@rutas.RutaDeTemp + "/rpt_ProdEmpacado.pdf"); vp.ShowDialog(); vp.Dispose(); wb.Close(false); app.Quit(); }
private void mostrarVistasPrevias() { VistasPrevias vp2 = new VistasPrevias(); vp2.Navegar(@rutasEnModAdmin.RutaDeTemp + "/new.pdf"); vp2.Show(); }