public void Export_User_Production_Report() { DateTime Fromdate = Convert.ToDateTime(From_date.ToString()); DateTime Todate = Convert.ToDateTime(To_date.ToString()); Logon_To_Crystal(); rptDoc.SetParameterValue("@Trans", "All"); rptDoc.SetParameterValue("@Order_Id", 0); rptDoc.SetParameterValue("@Client_Id", 0); rptDoc.SetParameterValue("@Subprocess_Id", 0); rptDoc.SetParameterValue("@Order_Progress_Id", 0); rptDoc.SetParameterValue("@Order_Status_Id", 0); rptDoc.SetParameterValue("@From_date", Fromdate); rptDoc.SetParameterValue("@To_date", Todate); rptDoc.SetParameterValue("@User_Id", 0); rptDoc.SetParameterValue("@Log_In_Userid", user_id); ExportOptions CrExportOptions; FileInfo newFile = new FileInfo(@"\\192.168.12.33\oms-reports\User_ProductionRep.xls"); DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); ExcelFormatOptions CrFormatTypeOptions = new ExcelFormatOptions(); CrDiskFileDestinationOptions.DiskFileName = newFile.ToString(); CrExportOptions = rptDoc.ExportOptions; CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = ExportFormatType.ExcelWorkbook; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; rptDoc.Export(); }
private void metroButton7_Click(object sender, EventArgs e) { RPT.rpt_all_products myReport = new RPT.rpt_all_products(); // Create Export options ExportOptions export = new ExportOptions(); // Create object for destination DiskFileDestinationOptions dfoptions = new DiskFileDestinationOptions(); ExcelFormatOptions excelformat = new ExcelFormatOptions(); // Set the path of destination dfoptions.DiskFileName = @"D:\scienses\life with c#\projects\Products Managemnt\Reports\ProductsList.xls"; export = myReport.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportFormatOptions = excelformat; export.ExportDestinationOptions = dfoptions; myReport.Refresh(); myReport.Export(); MessageBox.Show("List Eported Successfully ", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void button7_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; RPT.rpt_all_products myReport = new RPT.rpt_all_products(); //Create Export Options خاص باعداد التقرير ExportOptions export = new ExportOptions(); //Create Object For destination خاص بمكان حفظ التقرير DiskFileDestinationOptions dfoptions = new DiskFileDestinationOptions(); ExcelFormatOptions excelformat = new ExcelFormatOptions(); // تحديد مسار التخزين dfoptions.DiskFileName = @"E:\ProductsList.xls"; export = myReport.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportFormatOptions = excelformat; export.ExportDestinationOptions = dfoptions; myReport.Export(); this.Cursor = Cursors.Default; MessageBox.Show("E: ProductsList : تم حفظ الملف بنجاح ", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information); }
protected void butAddItem_Click(object sender, EventArgs e) { if (oPurchase != null) { PurchaseOrder cryRpt = new PurchaseOrder(); oPurchase.Print(cryRpt); try { ExportOptions CrExportOptions; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); ExcelFormatOptions CrFormatTypeOptions = new ExcelFormatOptions(); CrDiskFileDestinationOptions.DiskFileName = Server.MapPath("~/OutputFiles/") + "Purchase-" + oPurchase.ID + ".xls"; CrExportOptions = cryRpt.ExportOptions; CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = ExportFormatType.Excel; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; cryRpt.Export(); cryRpt = null; Response.Redirect("http://" + Request.ServerVariables["SERVER_NAME"] + "/OutputFiles/" + "Purchase-" + oPurchase.ID + ".xls"); } catch (Exception ex) { //MessageBox.Show(ex.ToString()); } } } //Purchases
private void buttonItem1_Click(object sender, EventArgs e) { CRClientesCompletos rptExcel = new CRClientesCompletos(); rptExcel.Load("CRClientesCompletos.rpt"); rptExcel.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; rptExcel.ExportOptions.ExportFormatType = ExportFormatType.Excel; ExcelFormatOptions objExcelOptions = new ExcelFormatOptions(); objExcelOptions.ExcelUseConstantColumnWidth = false; rptExcel.ExportOptions.ExportFormatOptions = objExcelOptions; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString(); saveFileDialog.Filter = "Document (*.xls)|*.xls"; 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 btn_sauvgarder_Click(object sender, EventArgs e) { if (txt_save_name.Text != "") { RPT.RPT_ALL_PRODUCTS report = new RPT.RPT_ALL_PRODUCTS(); DiskFileDestinationOptions Destination = new DiskFileDestinationOptions(); Destination.DiskFileName = @"C:\Users\Hamza's Laptop\OneDrive\Documents\" + txt_save_name.Text + ".xls"; ExcelFormatOptions excelFormat = new ExcelFormatOptions(); ExportOptions export = new ExportOptions(); export = report.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportDestinationOptions = Destination; export.ExportFormatOptions = excelFormat; report.Export(); MessageBox.Show("raport est Sauvgarder avec succée !!"); txt_save_name.Text = ""; } else { MessageBox.Show("Veuiller saisie le nom de fichier a sauvgarder !!"); return; } }
public void ExportarRelatorioExcel(string caminho_arquivo) { InicializaRpt(); foreach (var p in _relatorio.parametros) { relatorio.SetParameterValue(p.parametro, p.valor); } ExportOptions CrExportOptions; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); ExcelFormatOptions CrFormatTypeOptions = new ExcelFormatOptions(); CrDiskFileDestinationOptions.DiskFileName = caminho_arquivo; CrExportOptions = relatorio.ExportOptions;//Report document object has to be given here CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = ExportFormatType.Excel; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; relatorio.Export(); //((BasePage)this.Page).ResponsePdf(adExtratoPDF.caminho_arquivo, adExtratoPDF.nome_arquivo); //ResponsePdf(adExtratoPDF.caminho_arquivo, adExtratoPDF.nome_arquivo); }
private void button6_Click(object sender, EventArgs e) { string filedes = @"D:\stock proj\Products.xls"; if (File.Exists(filedes)) { File.Delete(filedes); } Reports.All_Products_Report report = new Reports.All_Products_Report(); report.Refresh(); //export options obj ExportOptions ex = new ExportOptions(); //create disk obj DiskFileDestinationOptions disk = new DiskFileDestinationOptions(); ExcelFormatOptions excel = new ExcelFormatOptions(); //set the path disk.DiskFileName = @"D:\stock proj\Products.xls"; ex = report.ExportOptions; ex.ExportDestinationType = ExportDestinationType.DiskFile; ex.ExportFormatType = ExportFormatType.Excel; ex.ExportFormatOptions = excel; ex.ExportDestinationOptions = disk; report.Export(); MessageBox.Show("Successfuly Stored", "Stored Report", MessageBoxButtons.OK, MessageBoxIcon.Information); }
//汽蚀试验导出报表按钮 private void button4_Click(object sender, EventArgs e) { ExcelFormatOptions excelFormat = new ExcelFormatOptions(); excelFormat.ExcelTabHasColumnHeadings = false; excelFormat.ExcelUseConstantColumnWidth = true; excelFormat.ExcelConstantColumnWidth = 24.0; string rptPath = string.Empty; if (radioButton1.Checked == true) { rptPath = AppDomain.CurrentDomain.BaseDirectory + "\\试验报表RPT\\汽蚀报表(中).rpt"; this.reportDocument1.Load(rptPath); 汽蚀试验模型 ds = this.GetRePortModel2(); this.reportDocument1.SetDataSource(ds); // this.reportDocument1.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.RichText, this.path + string.Format("\\汽蚀试验{0}(中).rtf", ds.基础数据表[0].型号规格)); this.reportDocument1.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, this.path + string.Format("\\汽蚀试验{0}(中).xls", ds.基础数据表[0].型号规格)); } else { rptPath = AppDomain.CurrentDomain.BaseDirectory + "\\试验报表RPT\\汽蚀报表(英).rpt"; this.reportDocument1.Load(rptPath); 汽蚀试验模型 ds = this.GetRePortModel2(); this.reportDocument1.SetDataSource(ds); // this.reportDocument1.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.RichText, this.path + string.Format("\\汽蚀试验{0}(英).rtf", ds.基础数据表[0].型号规格)); this.reportDocument1.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, this.path + string.Format("\\汽蚀试验{0}(英).xls", ds.基础数据表[0].型号规格)); } }
private void button7_Click(object sender, EventArgs e) { RPT.RPT_ALL_PRODUCTS myreport = new RPT.RPT_ALL_PRODUCTS(); //Create Export Options خاص باعدادات التقرير ExportOptions export = new ExportOptions(); //Create object for Destination خاص بمكان حفظ التقرير DiskFileDestinationOptions dfdoptions = new DiskFileDestinationOptions(); ExcelFormatOptions excelformat = new ExcelFormatOptions(); //set the path of destination رابط المسار الذى نريد وضع الملف فيه dfdoptions.DiskFileName = "E:\\Productslist.xls"; export = myreport.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportFormatOptions = excelformat; export.ExportDestinationOptions = dfdoptions; myreport.Export(); MessageBox.Show("List Exported Successfuly ! ", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void button7_Click(object sender, EventArgs e) { RPT.rpt_all_product myreport = new RPT.rpt_all_product(); //creat export options ExportOptions export = new ExportOptions(); //creat object for destination DiskFileDestinationOptions dfoptions = new DiskFileDestinationOptions(); ExcelFormatOptions excelformat = new ExcelFormatOptions(); //set the path of desyination dfoptions.DiskFileName = @"D:\producrslist.xls"; export = myreport.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportFormatOptions = excelformat; export.ExportDestinationOptions = dfoptions; myreport.Export(); MessageBox.Show("list exported successfully !", "export", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); }
private void sve_excel_Click(object sender, EventArgs e) { RPRT.CrystalReport_ALL_PRDCTS prd = new RPRT.CrystalReport_ALL_PRDCTS(); ExportOptions ex = new ExportOptions(); DiskFileDestinationOptions dist = new DiskFileDestinationOptions(); ExcelFormatOptions excel = new ExcelFormatOptions(); dist.DiskFileName = @"C:\Users\hima\Desktop\\Excel_Sheet.xls"; ex = prd.ExportOptions; ex.ExportDestinationType = ExportDestinationType.DiskFile; ex.ExportFormatType = ExportFormatType.Excel; ex.ExportFormatOptions = excel; ex.ExportDestinationOptions = dist; prd.Export(); MessageBox.Show("File Exported on Desktop Successfully", "INFO", MessageBoxButtons.OK); }
private void btnSavetoExcel_Click(object sender, EventArgs e) { RPT.RPT_ALL_Donations RPT_ALL_Donations = new RPT.RPT_ALL_Donations(); ExportOptions export = new ExportOptions(); DiskFileDestinationOptions diskFileDestination = new DiskFileDestinationOptions(); //To save it to execel ExcelFormatOptions excelFormat = new ExcelFormatOptions(); diskFileDestination.DiskFileName = @"E:\text.xls"; export = RPT_ALL_Donations.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportFormatOptions = excelFormat; export.ExportDestinationOptions = diskFileDestination; //end of save excel type //To save it to PDF /*PdfFormatOptions pdfFormat = new PdfFormatOptions(); * diskFileDestination.DiskFileName = @"E:\DonationsList.PDF"; * export = RPT_ALL_Donations.ExportOptions; * export.ExportDestinationType = ExportDestinationType.DiskFile; * export.ExportFormatType = ExportFormatType.PortableDocFormat; * export.ExportFormatOptions = pdfFormat; * export.ExportDestinationOptions = diskFileDestination; */ RPT_ALL_Donations.Export(); //end save it to PDF MessageBox.Show("Done!.."); }
private void btnSavetoExcel_Click(object sender, EventArgs e) { try { RPT.rpt_AllProductN report = new RPT.rpt_AllProductN(); //choose destination for a report DiskFileDestinationOptions destination = new DiskFileDestinationOptions(); ExportOptions export = new ExportOptions(); ExcelFormatOptions excelFormat = new ExcelFormatOptions(); FolderBrowserDialog fd = new FolderBrowserDialog(); fd.ShowDialog(); string df = fd.SelectedPath + "\\report.xls"; // destination.DiskFileName = "D:\\report.xls"; destination.DiskFileName = df; export = report.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportDestinationOptions = destination; export.ExportFormatOptions = excelFormat; report.Export(); MessageBox.Show("تم تصدير الملف بنجاح"); } catch (Exception ex) { MessageBox.Show("لا يمكن الوصول الى قاعدة البيانات لتصدير الملف نحتاج الى الدخول في وضعية وثوقية الويندوز "); } }
private void button8_Click(object sender, EventArgs e) { RPT.rpt_all_product myReport = new RPT.rpt_all_product(); // Create Object For destination for select path Save file DiskFileDestinationOptions dfoptions = new DiskFileDestinationOptions(); // Create Export Option ExportOptions export = new ExportOptions(); ExcelFormatOptions excelFormat = new ExcelFormatOptions(); // Set The path to save SaveFileDialog sf = new SaveFileDialog(); sf.Filter = "Save File (*.xls ) |*.xls"; if (sf.ShowDialog() == DialogResult.OK) { dfoptions.DiskFileName = sf.FileName; export = myReport.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportFormatOptions = excelFormat; export.ExportDestinationOptions = dfoptions; myReport.Export(); MessageBox.Show("تم حفظ ملف بالنجاح", "تم", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnSave_Click(object sender, EventArgs e) { RPT.rpt_all_products rpt = new RPT.rpt_all_products(); ExportOptions export = new ExportOptions(); export = rpt.ExportOptions; ExcelFormatOptions excelformat = new ExcelFormatOptions(); export.ExportFormatOptions = excelformat; export.ExportFormatType = ExportFormatType.Excel; DiskFileDestinationOptions dfoptions = new DiskFileDestinationOptions(); string ExcelReportsPath = Application.StartupPath.Substring(0, (Application.StartupPath.Length - 10)) + @"\ExcelReports\"; dfoptions.DiskFileName = ExcelReportsPath + "\\ProductsList-" + DateTime.Now.ToString("dddd, dd MMMM yyyy") + ".xls"; export.ExportDestinationOptions = dfoptions; export.ExportDestinationType = ExportDestinationType.DiskFile; rpt.Export(); MessageBox.Show("Products List Exported Successfully", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void ExportReport(ReportDocument oReport, string cFileName, ExportTypes oExportTypes, int nFirstPage, int nLastPage) { ExportOptions oExportOptions = new ExportOptions(); PdfRtfWordFormatOptions oFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions(); DiskFileDestinationOptions oDestinationOptions = ExportOptions.CreateDiskFileDestinationOptions(); switch (oExportTypes) { case ExportTypes.PDF: case ExportTypes.MSWord: oExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; PdfRtfWordFormatOptions oPDFFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions(); if (nFirstPage > 0 && nLastPage > 0) { oPDFFormatOptions.FirstPageNumber = nFirstPage; oPDFFormatOptions.LastPageNumber = nLastPage; oPDFFormatOptions.UsePageRange = true; } oExportOptions.ExportFormatOptions = oPDFFormatOptions; break; case ExportTypes.MSExcel: oExportOptions.ExportFormatType = ExportFormatType.Excel; ExcelFormatOptions oExcelFormatOptions = ExportOptions.CreateExcelFormatOptions(); if (nFirstPage > 0 && nLastPage > 0) { oExcelFormatOptions.FirstPageNumber = nFirstPage; oExcelFormatOptions.LastPageNumber = nLastPage; oExcelFormatOptions.UsePageRange = true; } oExcelFormatOptions.ExcelUseConstantColumnWidth = false; oExportOptions.ExportFormatOptions = oExcelFormatOptions; break; case ExportTypes.HTML: oExportOptions.ExportFormatType = ExportFormatType.HTML40; HTMLFormatOptions oHTMLFormatOptions = ExportOptions.CreateHTMLFormatOptions(); if (nFirstPage > 0 && nLastPage > 0) { oHTMLFormatOptions.FirstPageNumber = nFirstPage; oHTMLFormatOptions.LastPageNumber = nLastPage; oHTMLFormatOptions.UsePageRange = true; } // can set additional HTML export options here oExportOptions.ExportFormatOptions = oHTMLFormatOptions; break; } oDestinationOptions.DiskFileName = cFileName; oExportOptions.ExportDestinationOptions = oDestinationOptions; oExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; oReport.Export(oExportOptions); }
private static void GenerateReport(ReportDocument report) { report.SetParameterValue("Rok", 2020); report.ExportToDisk(ExportFormatType.PortableDocFormat, "raport1.pdf"); ExcelFormatOptions excelFormatOptions = ExportOptions.CreateExcelFormatOptions(); excelFormatOptions.ShowGridLines = true; }
void ExportCrystalReport(ReportDocument cryRpt, string formatExport, string pathReportGenerate) { if (string.IsNullOrEmpty(pathReportGenerate)) { throw new Exception("Path report generate not found"); } if (cryRpt == null) { throw new Exception("Resource not found"); } ExportFormatType exportFormatType = ExportFormatType.NoFormat; string extensionFile = Path.GetExtension(pathReportGenerate); object formatOption = new PdfRtfWordFormatOptions(); switch (formatExport) { case "WORD": exportFormatType = ExportFormatType.WordForWindows; extensionFile = ".doc"; break; case "PDF": exportFormatType = ExportFormatType.PortableDocFormat; break; case "EXCEL": exportFormatType = ExportFormatType.Excel; extensionFile = ".xls"; formatOption = new ExcelFormatOptions(); break; } var downloadReportPath = System.Web.Hosting.HostingEnvironment.MapPath("~/DownloadReports/"); //Check exist folder DownloadReports if (!Directory.Exists(downloadReportPath)) { Directory.CreateDirectory(downloadReportPath); } DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); CrDiskFileDestinationOptions.DiskFileName = pathReportGenerate; ExportOptions CrExportOptions = cryRpt.ExportOptions; { CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = exportFormatType; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = formatOption; } cryRpt.Export(); }
//-----------------Controllers private async Task <int> GenerarReporteExcelAsync(DateTime fechaInicio, DateTime fechaFin, string nomArchivo) { SqlConnectionStringBuilder sqlStrBuilder = new SqlConnectionStringBuilder(ObtenerCadenaConexionAppController()); //http://aspalliance.com/478_Exporting_to_Excel_in_Crystal_Reports_NET__Perfect_Excel_Exports.3 //https://www.c-sharpcorner.com/UploadFile/mahesh/savefiledialog-in-C-Sharp/ CRReporteSociosProductosPagadosYNoPagadosParaExportar reporte = new CRReporteSociosProductosPagadosYNoPagadosParaExportar(); //reporte.SetDatabaseLogon("sa", "modomixto", "CRUZ2-THINK", "DBCajaCuentas2"); reporte.SetDatabaseLogon(sqlStrBuilder.UserID, sqlStrBuilder.Password, sqlStrBuilder.DataSource, sqlStrBuilder.InitialCatalog); reporte.SetParameterValue("@fechaInicio", fechaInicio); reporte.SetParameterValue("@fechaFin", fechaFin); //El subreporte cero es el ultimo subreporte y el subreporte 1 es el primer subreporte reporte.SetParameterValue("@fechaInicio", fechaInicio, reporte.Subreports[0].Name.ToString()); reporte.SetParameterValue("@fechaFin", fechaFin, reporte.Subreports[0].Name.ToString()); reporte.SetParameterValue("@fechaInicio", fechaInicio, reporte.Subreports[1].Name.ToString()); reporte.SetParameterValue("@fechaFin", fechaFin, reporte.Subreports[1].Name.ToString()); //Ponerle las fechas de busqueda al reporte TextObject periodoDeBusquedaTextObject = reporte.ReportDefinition.ReportObjects["Text6"] as TextObject; periodoDeBusquedaTextObject.Text = MuestraFechaDeBusquedaSinLaHora(fechaInicio) + " a " + MuestraFechaDeBusquedaSinLaHora(fechaFin); periodoDeBusquedaTextObject = reporte.Subreports[0].ReportDefinition.ReportObjects["Text6"] as TextObject; periodoDeBusquedaTextObject.Text = MuestraFechaDeBusquedaSinLaHora(fechaInicio) + " a " + MuestraFechaDeBusquedaSinLaHora(fechaFin); periodoDeBusquedaTextObject = reporte.Subreports[1].ReportDefinition.ReportObjects["Text6"] as TextObject; periodoDeBusquedaTextObject.Text = MuestraFechaDeBusquedaSinLaHora(fechaInicio) + " a " + MuestraFechaDeBusquedaSinLaHora(fechaFin); // Declare variables and get the export options. ExportOptions exportOpts = new ExportOptions(); ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions(); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions(); exportOpts = reporte.ExportOptions; // Set the excel format options. excelFormatOpts.ExcelUseConstantColumnWidth = false; excelFormatOpts.ShowGridLines = true; //exportOpts.ExportFormatType = ExportFormatType.ExcelRecord; exportOpts.ExportFormatType = ExportFormatType.Excel; exportOpts.FormatOptions = excelFormatOpts; // Set the disk file options and export. exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; //diskOpts.DiskFileName = "miotroreporttttte.xls"; diskOpts.DiskFileName = nomArchivo; exportOpts.DestinationOptions = diskOpts; reporte.Export(); await Task.Delay(200); return(1); }
protected void btnexport_Click(object sender, EventArgs e) { ReportDocument rptExcel = new ReportDocument(); string Degree = "0"; if (ddlDegree.SelectedValue == "9") { Degree = "9"; } string Term = "0"; if (ddlTerm.SelectedIndex != 0) { Term = ddlTerm.SelectedValue; } string connection; SqlConnection con = null; connection = ConfigurationManager.ConnectionStrings["SkyLineConnection"].ToString(); con = new SqlConnection(connection); SqlCommand cmd = new SqlCommand("SP_STUDENTMASTERFILE", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@TERMID", Term); cmd.Parameters.Add("@degreetypeid", Degree); cmd.Parameters.Add("@groupcode", ddlCountry.SelectedValue); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; cmd.CommandTimeout = 300; Server.ScriptTimeout = 3000000; DataTable datatable = new DataTable(); da.Fill(datatable); string strExportFile = Server.MapPath(".") + "/StudentMasterfile.xls"; rptExcel.Load(Server.MapPath("~/Report/STUDENTLIST.rpt")); rptExcel.SetDataSource(datatable); rptExcel.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; rptExcel.ExportOptions.ExportFormatType = ExportFormatType.Excel; ExcelFormatOptions objExcelOptions = new ExcelFormatOptions(); objExcelOptions.ExcelUseConstantColumnWidth = false; rptExcel.ExportOptions.FormatOptions = objExcelOptions; DiskFileDestinationOptions objOptions = new DiskFileDestinationOptions(); objOptions.DiskFileName = strExportFile; rptExcel.ExportOptions.DestinationOptions = objOptions; rptExcel.SetDatabaseLogon("software", "DelFirMENA$idea"); rptExcel.Export(); objOptions = null; rptExcel = null; Response.Redirect("StudentMasterfile.xls"); }
private void ExportReport(string FileName, ExportFormatType FileFormat) { if ((FileFormat == ExportFormatType.Excel)) { ExcelFormatOptions excelOpts = new ExcelFormatOptions(); rpt.ExportOptions.FormatOptions = excelOpts; } rpt.ExportToStream(FileFormat); rpt.Dispose(); rpt.Close(); }
private async void button2_Click(object sender, EventArgs e) { try { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { DeshabilitarButtons(); IniciarProgressBar(); string nomArchivo = saveFileDialog1.FileName; SqlConnectionStringBuilder sqlStrBuilder = new SqlConnectionStringBuilder(ObtenerCadenaConexionAppController()); //http://aspalliance.com/478_Exporting_to_Excel_in_Crystal_Reports_NET__Perfect_Excel_Exports.3 //https://www.c-sharpcorner.com/UploadFile/mahesh/savefiledialog-in-C-Sharp/ CRReporteSociosParaExportar reporte = new CRReporteSociosParaExportar(); //reporte.SetDatabaseLogon("sa", "modomixto", "CRUZ2-THINK", "DBCajaCuentas2"); reporte.SetDatabaseLogon(sqlStrBuilder.UserID, sqlStrBuilder.Password, sqlStrBuilder.DataSource, sqlStrBuilder.InitialCatalog); reporte.SetParameterValue("@parametroNoNecesario", true); // Declare variables and get the export options. ExportOptions exportOpts = new ExportOptions(); ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions(); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions(); exportOpts = reporte.ExportOptions; // Set the excel format options. excelFormatOpts.ExcelUseConstantColumnWidth = false; excelFormatOpts.ShowGridLines = true; //exportOpts.ExportFormatType = ExportFormatType.ExcelRecord; exportOpts.ExportFormatType = ExportFormatType.Excel; exportOpts.FormatOptions = excelFormatOpts; // Set the disk file options and export. exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; //diskOpts.DiskFileName = "miotroreporttttte.xls"; diskOpts.DiskFileName = nomArchivo; exportOpts.DestinationOptions = diskOpts; reporte.Export(); await Task.Delay(10); DetenerProgressBar(); HabilitarButtons(); MessageBox.Show("Exportacion lista", "Resultado de operación", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { DetenerProgressBar(); HabilitarButtons(); MessageBox.Show(ex.Message + " " + ex.Source + " " + ex.StackTrace); } }
private void frmRImprimirDetalleCompra_Load(object sender, EventArgs e) { try { ExcelFormatOptions objExcel = new ExcelFormatOptions(); int idProducto = Convert.ToInt32(frmMostrarCompras.f1.lblIdCompra.Text); ReportDocument repdoc = new ReportDocument(); // repdoc.Load(@"C:\Users\vioma\OneDrive\Documentos\Visual Studio 2017\Projects\SisVentas_ResAlm\CapaPresentacion\Reportes/RVentaProducto.rpt"); repdoc.Load(@"D:\Reportes\RImprimirDetalleCompra.rpt"); ParameterFieldDefinitions pfds; ParameterFieldDefinition pfd; ParameterValues pvs = new ParameterValues(); ParameterDiscreteValue pdv = new ParameterDiscreteValue(); pdv.Value = idProducto; pfds = repdoc.DataDefinition.ParameterFields; pfd = pfds["@idCompra"]; pvs.Add(pdv); pfd.ApplyCurrentValues(pvs); TableLogOnInfos crtableLogoninfos = new TableLogOnInfos(); TableLogOnInfo crtableLogoninfo = new TableLogOnInfo(); ConnectionInfo crConnectionInfo = new ConnectionInfo(); Tables CrTables; crConnectionInfo.ServerName = @"EQUIPO\SQLEXPRESS"; crConnectionInfo.DatabaseName = "SIS_AVICOLA"; crConnectionInfo.UserID = "admin"; crConnectionInfo.Password = "******"; CrTables = repdoc.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) { crtableLogoninfo = CrTable.LogOnInfo; crtableLogoninfo.ConnectionInfo = crConnectionInfo; CrTable.ApplyLogOnInfo(crtableLogoninfo); } cvVentas.ReportSource = repdoc; cvVentas.Refresh(); objExcel.ExcelUseConstantColumnWidth = false; } catch (Exception ex) { MessageBox.Show("ERROR" + ex); } }
private void btn_imprimir_Click(object sender, EventArgs e) { string root = @"N:\EXCEL"; String fileName = @"N:\EXCEL\"; if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } try { btn_imprimir.Enabled = false; int index = grd_Facturas.SelectedCells[0].RowIndex; objDocumentoCab = objListaDocumentoCab[index]; formatearLetra(); fileName = fileName + objDocumentoCab.DocumentoCabSerie.Substring(0, 1) + "-" + objDocumentoCab.DocumentoCabNro + ".xls"; Letras cr = new Letras(); cr.SetDataSource(objListaLetraReporte); ExportOptions exportOpts = new ExportOptions(); ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions(); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions(); exportOpts = cr.ExportOptions; // Set the excel format options. excelFormatOpts.ExcelUseConstantColumnWidth = true; excelFormatOpts.ExcelTabHasColumnHeadings = true; excelFormatOpts.ShowGridLines = true; exportOpts.ExportFormatType = ExportFormatType.Excel; exportOpts.FormatOptions = excelFormatOpts; // Set the disk file options and export. exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; diskOpts.DiskFileName = fileName; exportOpts.DestinationOptions = diskOpts; cr.Export(); PrintMyExcelFile(fileName); btn_imprimir.Enabled = true; } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); btn_imprimir.Enabled = true; } }
private void exportpdf_Click(object sender, EventArgs e) { RPT.rpt_all_product myreport = new RPT.rpt_all_product(); ExportOptions export = new ExportOptions(); DiskFileDestinationOptions dfoption = new DiskFileDestinationOptions(); ExcelFormatOptions excelformat = new ExcelFormatOptions(); dfoption.DiskFileName = @"E:\\" + "list" + ".xml"; export = myreport.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportFormatOptions = excelformat; export.ExportDestinationOptions = dfoption; MessageBox.Show("تمت عمليه التصدير بنجاح ", "عمليه التصدير", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void StockAvailable(string receiveNo, string reportType) { conn = new SqlConnection(connTaap); rptDoc = new ReportDocument(); try { conn.Open(); string sqlQry = "dbo.sp_rptStockAvailable '" + receiveNo + "'"; var dt = new DataTable(); var da = new SqlDataAdapter(sqlQry, conn); da.Fill(dt); var file = reportType == "excel" ? "./SotckAvailableExcel.rpt" : "./SotckAvailable.rpt"; rptDoc.Load(Server.MapPath(file)); rptDoc.Refresh(); rptDoc.SetDataSource(dt); rptDoc.SetParameterValue("@ReceiveNo", receiveNo); // Declare variables and get the export options. ExportOptions exportOpts = new ExportOptions(); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions(); exportOpts = rptDoc.ExportOptions; if (reportType == "excel") { ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions(); excelFormatOpts.ExcelUseConstantColumnWidth = true; excelFormatOpts.ExcelAreaType = AreaSectionKind.Detail; exportOpts.ExportFormatType = ExportFormatType.Excel; exportOpts.FormatOptions = excelFormatOpts; } else { exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat; } rptDoc.ExportToHttpResponse(exportOpts, Response, true, "Report-Stock-Available"); } catch (Exception ex) { Response.Write(ex.Message); } finally { conn.Close(); rptDoc.Close(); } }
protected void BtnExport_Click(object sender, EventArgs e) { string rptFullPath = Server.MapPath(@".\RptFiles\MachineSurveys\STREETS_SECTIONS_LANE_GIS.rpt"); DataTable dt = new JpmmsClasses.BL.MainStreet().GetSectionsDetailsSYS(ddlRegions.SelectedValue); ReportDocument rpt = new ReportDocument(); rpt.Load(rptFullPath); rpt.SetDataSource(dt); Stream memStream; Response.Buffer = false; Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); if (false) { ExcelFormatOptions excelOptions = new ExcelFormatOptions(); excelOptions.ExcelUseConstantColumnWidth = false; rpt.ExportOptions.FormatOptions = excelOptions; memStream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.ExcelRecord); Response.ContentType = "application/vnd.ms-excel"; } else if (false) { memStream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.WordForWindows); Response.ContentType = "application/doc"; } else { memStream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); Response.ContentType = "application/pdf"; } byte[] ArryStream = new byte[memStream.Length + 1]; memStream.Read(ArryStream, 0, System.Convert.ToInt32(memStream.Length)); Response.BinaryWrite(ArryStream); Response.End(); memStream.Flush(); memStream.Close(); memStream.Dispose(); rpt.Close(); rpt.Dispose(); GC.Collect(); }
private void btnExportExcel_Click(object sender, EventArgs e) { RPT.rpt_All_products myReport = new RPT.rpt_All_products(); ExportOptions export = new ExportOptions(); DiskFileDestinationOptions defile = new DiskFileDestinationOptions(); ExcelFormatOptions excelformat = new ExcelFormatOptions(); defile.DiskFileName = @"D:\MYReport.xls"; export = myReport.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportFormatOptions = excelformat; export.ExportDestinationOptions = defile; myReport.Export(); MessageBox.Show("Report Exported Successfully", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void PrintReportDocumentoInacassi(AbstractDocumentController controllerDocument, ControllerIncassiQuote controllerIncassi) { if ((controllerDocument != null) && (controllerIncassi != null)) { GeneratorDocumentoIncassi generatorReportIncassiQuote = new GeneratorDocumentoIncassi(controllerDocument, controllerIncassi); WIN.GUI.PRINT.Report.ReportDocumentiIncassi ReportIncassiQuote = new WIN.GUI.PRINT.Report.ReportDocumentiIncassi(); ReportIncassiQuote.SetDataSource(generatorReportIncassiQuote.GeneraDataSet()); generatorReportIncassiQuote.SetHeaderInfo(ReportIncassiQuote); generatorReportIncassiQuote.SetFooterInfo(ReportIncassiQuote); ExcelFormatOptions option = CrystalDecisions.Shared.ExportOptions.CreateExcelFormatOptions(); string fileTmp = System.IO.Path.GetTempFileName(); string fileTmpXls = fileTmp.Replace(".tmp", ".xls"); ReportIncassiQuote.ExportToDisk(ExportFormatType.Excel, fileTmpXls); System.Diagnostics.Process.Start(fileTmpXls); } }
//Exporta a Excel el grid protected void ExportEstimacionCostos(object sender, EventArgs e) { string parametro = cmbClasificacion.Value.ToString(); //1. Configurar la conexión y el tipo de comando SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString); try { SqlCommand comando = new SqlCommand("web_spS_ObtenerConceptosRevisados", conn); SqlDataAdapter adaptador = new SqlDataAdapter(comando); DataTable dt = new DataTable(); adaptador.SelectCommand.CommandType = CommandType.StoredProcedure; adaptador.SelectCommand.Parameters.Add(@"CLASIFICACION", SqlDbType.VarChar).Value = parametro; adaptador.Fill(dt); ReportDocument rCaratulaEstimacionCostos = new ReportDocument(); rCaratulaEstimacionCostos.Load(Server.MapPath("reportess/rCaratulaEstimacionDeCostos.rpt")); rCaratulaEstimacionCostos.SetDataSource(dt); rCaratulaEstimacionCostos.SetParameterValue("pProveedor", "A & R Construcciones S.A de C.V"); rCaratulaEstimacionCostos.SetParameterValue("pathlogo", Server.MapPath(" ") + "\\images\\clientes\\"); ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions(); excelFormatOpts.ExcelUseConstantColumnWidth = false; rCaratulaEstimacionCostos.ExportOptions.FormatOptions = excelFormatOpts; rCaratulaEstimacionCostos.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, true, "Reportes Mantenimiento " + parametro); } catch (Exception ex) { ex.Message.ToString(); }finally{ if (conn.State != ConnectionState.Closed) conn.Close(); conn.Dispose(); } }
/// //////////////////////////////////////////////////////////////////////// /// EVENTS /// protected void Page_Load(object sender, System.EventArgs e) { //--- Security check if (!Convert.ToBoolean(Session["sgLFS_APP_VIEW"])) { Response.Redirect("./../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } //--- Validate query string if ((Request.QueryString["target_report"] == null) || (Request.QueryString["format"] == null)) { Response.Redirect("./../error_page.aspx?error=" + "Invalid query string in viewer.aspx"); } //--- Initialize bool empty = false; LFSRecordForReportsGateway lfsRecordForReportsGateway = new LFSRecordForReportsGateway(); //--- Get report data #region Get report data switch (Request.QueryString["target_report"]) { //--- CXIRemovedReport case "CXIRemovedReport": TDSCXIRemovedReport dataSet = lfsRecordForReportsGateway.GetCXIRemovedReportByCompanyId(Convert.ToInt32(Session["companyID"])); if (dataSet.CXIRemovedReport.Rows.Count > 0) { report = new rCXIRemovedReport(); report.SetDataSource(dataSet); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- ReadyForLining case "ReadyForLining": TDSReadyForLining tdsReadyForLining = lfsRecordForReportsGateway.GetReadyForLiningByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsReadyForLining.ReadyForLining.Rows.Count > 0) { report = new rReadyForLining(); report.SetDataSource(tdsReadyForLining); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; //--- ToBePrepped case "ToBePrepped": TDSToBePrepped tdsToBePrepped = lfsRecordForReportsGateway.GetToBePreppedByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsToBePrepped.ToBePrepped.Rows.Count > 0) { report = new rToBePrepped(); report.SetDataSource(tdsToBePrepped); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; //--- ToBeMeasured case "ToBeMeasured": TDSToBeMeasured tdsToBeMeasured = lfsRecordForReportsGateway.GetToBeMeasuredByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsToBeMeasured.ToBeMeasured.Rows.Count > 0) { report = new rToBeMeasured(); report.SetDataSource(tdsToBeMeasured); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; //--- LiningCompleted case "LiningCompleted": TDSLiningCompleted tdsLiningCompleted = lfsRecordForReportsGateway.GetLiningCompletedByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"]), Convert.ToDateTime(Request.QueryString["start_date"]), Convert.ToDateTime(Request.QueryString["end_date"])); if (tdsLiningCompleted.LiningCompleted.Rows.Count > 0) { report = new rLiningCompleted(); report.SetDataSource(tdsLiningCompleted); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- OverviewReport case "OverviewReport": TDSOverviewReport tdsOverviewReport = lfsRecordForReportsGateway.GetOverviewReportByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsOverviewReport.OverviewReport.Rows.Count > 0) { report = new rOverviewReport(); report.SetDataSource(tdsOverviewReport); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; //--- RehabAssessmentAreas case "RehabAssessmentAreas": TDSRehabAssessmentAreas tdsRehabAssessmentAreas = lfsRecordForReportsGateway.GetRehabAssessmentAreasByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsRehabAssessmentAreas.RehabAssessmentAreas.Rows.Count > 0) { report = new rRehabAssessmentAreas(); report.SetDataSource(tdsRehabAssessmentAreas); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; //--- AllOutstandingIssues case "AllOutstandingIssues": TDSAllOutstandingIssues tdsAllOutstandingIssues = lfsRecordForReportsGateway.GetAllOutstandingIssuesByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsAllOutstandingIssues.AllOutstandingIssues.Rows.Count > 0) { report = new rAllOutstandingIssues(); report.SetDataSource(tdsAllOutstandingIssues); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- OutstandingClientIssues case "OutstandingClientIssues": TDSOutstandingClientIssues tdsOutstandingClientIssues = lfsRecordForReportsGateway.GetOutstandingClientIssuesByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsOutstandingClientIssues.OutstandingClientIssues.Rows.Count > 0) { report = new rOutstandingClientIssues(); report.SetDataSource(tdsOutstandingClientIssues); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- OutstandingLFSIssues case "OutstandingLFSIssues": TDSOutstandingLFSIssues tdsOutstandingLFSIssues = lfsRecordForReportsGateway.GetOutstandingLFSIssuesByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsOutstandingLFSIssues.OutstandingLFSIssues.Rows.Count > 0) { report = new rOutstandingLFSIssues(); report.SetDataSource(tdsOutstandingLFSIssues); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- OutstandingInvestigationIssues case "OutstandingInvestigationIssues": TDSOutstandingInvestigationIssues tdsOutstandingInvestigationIssues = lfsRecordForReportsGateway.GetOutstandingInvestigacionIssuesByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsOutstandingInvestigationIssues.OutstandingInvestigationUssue.Rows.Count > 0) { report = new rOutstandingInvestigationIssues(); report.SetDataSource(tdsOutstandingInvestigationIssues); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- OutstandingSalesIssues case "OutstandingSalesIssues": TDSOutstandingSalesIssues tdsOutstandingSalesIssues = lfsRecordForReportsGateway.GetOutstandingSalesIssuesByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsOutstandingSalesIssues.OutstandingSalesIssues.Rows.Count > 0) { report = new rOutstandingSalesIssues(); report.SetDataSource(tdsOutstandingSalesIssues); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- ClientInvestigationIssuesCityCopy case "ClientInvestigationIssuesCityCopy": TDSClientInvestigationIssuesCityCopy tdsClientInvestigationIssuesCityCopy = lfsRecordForReportsGateway.GetClientInvestigationIssuesCityCopyByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsClientInvestigationIssuesCityCopy.ClientInvestigationIssuesCityCopy.Rows.Count > 0) { report = new rClientInvestigationIssuesCityCopy(); report.SetDataSource(tdsClientInvestigationIssuesCityCopy); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- PointLinerReport case "PointLinerReport": TDSPointLinerReport tdsPointLinerReport = lfsRecordForReportsGateway.GetPointLinerReportByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsPointLinerReport.PointLinerReport.Rows.Count > 0) { report = new rPointLinerReport(); report.SetDataSource(tdsPointLinerReport); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; //--- PointLinerScopeSheet case "PointLinerScopeSheet": TDSPointLinerScopeSheet tdsPointLinerScopeSheet = lfsRecordForReportsGateway.GetPointLinerScopeSheetByCompanyId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsPointLinerScopeSheet.PointLinerScopeSheet.Rows.Count > 0) { report = new rPointLinerScopeSheet(); report.SetDataSource(tdsPointLinerScopeSheet); report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; //--- OutstandingPointRepairs case "OutstandingPointRepairsReport": TDSOutstandingPointRepairs tdsOutstandingPointRepairs = lfsRecordForReportsGateway.GetOutstandingPointRepairsCompanyIdCompaniesId(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsOutstandingPointRepairs.OutstandingPointRepairs.Rows.Count > 0) { //--- Report creation and data binding report = new rOutstandingPointRepairs(); report.SetDataSource(tdsOutstandingPointRepairs); //--- Format control if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } //--- Report format report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; //--- M1ReportByClient case "M1ReportByClient": TDSM1ReportByClient tdsM1ReportByClient; if ((Request.QueryString["id"] != "0") && (Request.QueryString["companies"] == "0") && (Request.QueryString["date"] == "0")) { tdsM1ReportByClient = lfsRecordForReportsGateway.GetM1ReportByClientByCompanyIdByID(Convert.ToInt32(Session["companyID"]), Request.QueryString["id"]); } else if ((Request.QueryString["id"] == "0") && (Convert.ToInt32(Request.QueryString["companies"]) != 0) && (Request.QueryString["date"] == "0")) { tdsM1ReportByClient = lfsRecordForReportsGateway.GetM1ReportByClientByCompanyIdByCompanies(Convert.ToInt32(Session["companyID"]), Convert.ToInt32(Request.QueryString["companies"])); } else { tdsM1ReportByClient = lfsRecordForReportsGateway.GetM1ReportByClientByCompanyIdByDate(Convert.ToInt32(Session["companyID"]), Request.QueryString["date"]); } if (tdsM1ReportByClient.M1ReportByClient.Rows.Count > 0) { report = new rM1ReportByClient(); report.SetDataSource(tdsM1ReportByClient); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- M2ReportByID case "M2ReportByID": TDSM2ReportByID tdsM2ReportByID; if ((Request.QueryString["id"] != "0") && (Request.QueryString["companies"] == "0") && (Request.QueryString["date"] == "0")) { tdsM2ReportByID = lfsRecordForReportsGateway.GetM2ReportByIDByCompanyIdById(Convert.ToInt32(Session["companyID"]), Request.QueryString["id"]); } else if ((Request.QueryString["id"] == "0") && (Convert.ToInt32(Request.QueryString["companies"]) != 0) && (Request.QueryString["date"] == "0")) { tdsM2ReportByID = lfsRecordForReportsGateway.GetM2ReportByIDByCompanyIdByCompanies(Convert.ToInt32(Session["companyID"]), Convert.ToInt32(Request.QueryString["companies"])); } else { tdsM2ReportByID = lfsRecordForReportsGateway.GetM2ReportByIDByCompanyIdByDate(Convert.ToInt32(Session["companyID"]), Request.QueryString["date"]); } if (tdsM2ReportByID.LFS_MASTER_AREA.Rows.Count > 0) { report = new rM2ReportByID(); report.SetDataSource(tdsM2ReportByID); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- WorkAhead case "WorkAhead": TDSWorkAhead tdsWorkAhead = lfsRecordForReportsGateway.GetWorkAheadByCompanyId(Convert.ToInt32(Session["companyID"])); if (tdsWorkAhead.WorkAhead1.Rows.Count > 0) { report = new rWorkAhead(); report.SetDataSource(tdsWorkAhead); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; //--- JLinerOverviewReport case "JLinerOverviewReport": TDSJLinerOverviewReport tdsJLinerOverviewReport = lfsRecordForReportsGateway.GetJLinerOverviewReportByCompanyIDCompaniesID(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsJLinerOverviewReport.JLinerOverviewReport.Rows.Count > 0) { //---Report creation and data binding if (Convert.ToBoolean(Session["sgLFS_APP_ADMIN"])) { report = new rJLinerOverviewReport(); } else { report = new rJLinerOverviewReportSimple(); } report.SetDataSource(tdsJLinerOverviewReport); //---Format control if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } //---Report format report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; //--- JLinersReadyToLine case "JLinersReadyToLine": TDSJLinersReadyToLine tdsJLinersReadyToLine = lfsRecordForReportsGateway.GetJLinersReadyToLineByCompanyIDCompaniesID(Convert.ToInt32(Session["companyID"]), Convert.ToBoolean(Request.QueryString["all_clients"]), Convert.ToInt32(Request.QueryString["companies_id"])); if (tdsJLinersReadyToLine.JLinersReadyToLine.Rows.Count > 0) { //---Report creation and data binding report = new rJLinersReadyToLine(); report.SetDataSource(tdsJLinersReadyToLine); //---Format control if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } //---Report format report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; //--- JLinersToBuild case "JLinersToBuild": TDSJLinersToBuild tdsJLinersToBuild = lfsRecordForReportsGateway.GetJLinersToBuildByCompanyId(Convert.ToInt32(Session["companyID"])); if (tdsJLinersToBuild.JLinersToBuild.Rows.Count > 0) { report = new rJLinersToBuild(); report.SetDataSource(tdsJLinersToBuild); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; report.PrintOptions.PaperSize = PaperSize.PaperLetter; } else { empty = true; } break; } #endregion if (!empty) { //--- Configure report //--- ... Disk options string physicalApplicationPath = Request.PhysicalApplicationPath; if (Request.PhysicalApplicationPath.Substring(Request.PhysicalApplicationPath.Length-1, 1) != "\\") { physicalApplicationPath += "\\"; } string fName = ""; switch (Request.QueryString["format"]) { case "pdf": fName = physicalApplicationPath + "export\\" + Guid.NewGuid().ToString() + ".pdf"; Session["fName"] = fName; break; case "excel": fName = physicalApplicationPath + "export\\" + Guid.NewGuid().ToString() + ".xls"; Session["fName"] = fName; break; case "word": break; } DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions(); diskOptions.DiskFileName = fName; //--- ... Export options report.ExportOptions.DestinationOptions = diskOptions; report.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; switch (Request.QueryString["format"]) { case "pdf": report.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; break; case "excel": ExcelFormatOptions excelOptions = new ExcelFormatOptions(); excelOptions.ExcelUseConstantColumnWidth = false; excelOptions.ExcelTabHasColumnHeadings = false; report.ExportOptions.ExportFormatType = ExportFormatType.Excel; report.ExportOptions.FormatOptions = excelOptions; break; case "word": break; } //--- Export report try { report.Export(); } catch(Exception ex) { Response.Redirect("./../error_page.aspx?error=" + ex.Message); } //--- Preview report Response.Redirect("viewer2.aspx?target_report=" + Request.QueryString["target_report"] + "&format=" + Request.QueryString["format"], true); } else { Response.Write("<br> No records found for your report."); } }
public override void Start() { FrmProgress frmProgreso = new FrmProgress(); frmProgreso.Start(2, "Exportando ..."); frmProgreso.Next(); try { CReporte reporte = null; ExportFormatOptions opciones = null; ExportFormatType formato; string nombreArchivo = string.Empty; string extension = string.Empty; string sql = string.Empty; if (base.m_ObjectFlow is DocumentoGenerico) { DocumentoGenerico documento = (DocumentoGenerico)base.m_ObjectFlow; reporte = documento.TipoDocumento.Reporte; nombreArchivo = string.Format("{0} - Nº {1} {2}", reporte.Nombre, documento.Numeracion, DateTime.Now.ToString("yyyy-MM-dd")); sql = reporte.SQL; foreach (ParametroReporte Parametro in reporte.ParametrosSQL) sql = sql.Replace(Parametro.Nombre, documento.ValueByProperty(Parametro.Propiedad).ToString()); } else if (base.m_ObjectFlow is CReporte) { reporte = (CReporte)base.m_ObjectFlow; nombreArchivo = string.Format("{0} {1}", reporte.Nombre, DateTime.Now.ToString("yyyy-MM-dd")); sql = reporte.SQL; foreach (ParametroReporte Parametro in reporte.ParametrosSQL) sql = sql.Replace(Parametro.Nombre, Parametro.Valor); } switch (base.m_Parameter) { case TypeEnum.CEnumExportFormat.PDF: formato = ExportFormatType.PortableDocFormat; opciones = new PdfRtfWordFormatOptions(); extension = ".pdf"; break; case TypeEnum.CEnumExportFormat.WORD: formato = ExportFormatType.WordForWindows; opciones = new PdfRtfWordFormatOptions(); extension = ".doc"; break; case TypeEnum.CEnumExportFormat.EXCEL: formato = ExportFormatType.Excel; opciones = new ExcelFormatOptions(); extension = ".xls"; break; default: throw new Exception("El formato no es válido."); } if (reporte != null) { ReportDocument CryRpt = new ReportDocument(); CryRpt.Load(String.Format("{0}{1}", FrmMain.CarpetaReportes, reporte.Ubicacion)); frmProgreso.Next(); // Si existe una consulta SQL se ejecuta. if (sql.Trim().Length > 0) { CryRpt.SetDataSource(HelperNHibernate.GetDataSet(sql)); } // Se reemplazan los parámetros Crystal. foreach (ParametroReporte Parametro in reporte.ParametrosCrystal) CryRpt.SetParameterValue(Parametro.Nombre, Parametro.Valor); // Se exporta el reporte. ExportOptions CrExportOptions; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); CrDiskFileDestinationOptions.DiskFileName = string.Format("{0}{1}{2}", FrmMain.CarpetaExportacion, nombreArchivo, extension); CrExportOptions = CryRpt.ExportOptions; { CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = formato; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = opciones; } // Se exporta el archivo. CryRpt.Export(); // Se inicia un proceso para abrir el archivo. Process.Start(CrDiskFileDestinationOptions.DiskFileName); } else throw new Exception("Entidad no válida."); base.m_ResultProcess = EnumResult.SUCESS; } catch (Exception ex) { SoftException.Control(ex); } finally { frmProgreso.Close(); base.Start(); } }
private void button7_Click(object sender, EventArgs e) { this.dataGridView1.DataSource = prd.GET_ALL_PRODUCTS(); RPT.RPT_ALL_PRD myReport = new RPT.RPT_ALL_PRD(); //Create Export Options ExportOptions export = new ExportOptions(); //Create Object For Destination DiskFileDestinationOptions dfOptionXLS = new DiskFileDestinationOptions(); DiskFileDestinationOptions dfOptionPDF = new DiskFileDestinationOptions(); PdfFormatOptions pdfFormat = new PdfFormatOptions(); ExcelFormatOptions excelFormat = new ExcelFormatOptions(); //Set The Path of Destination For XLS saveFileDialog1.Filter = "Text Files | *.XLS"; saveFileDialog1.InitialDirectory = "D:\\"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { dfOptionXLS.DiskFileName = saveFileDialog1.FileName; } //dfOptionXLS.DiskFileName = @"D:\PRODUCTLIST.xls"; export = myReport.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.Excel; export.ExportFormatOptions = excelFormat; export.ExportDestinationOptions = dfOptionXLS; myReport.Export(); MessageBox.Show("List XLS Exported Successfully", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information); //Set The Path of Destination For PDF //dfOptionPDF.DiskFileName = @"D:\PRODUCTLIST.PDF"; saveFileDialog1.FileName = ""; saveFileDialog1.Filter = "Text Files | *.PDF"; saveFileDialog1.InitialDirectory = "D:\\"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { dfOptionPDF.DiskFileName = saveFileDialog1.FileName; } export = myReport.ExportOptions; export.ExportDestinationType = ExportDestinationType.DiskFile; export.ExportFormatType = ExportFormatType.PortableDocFormat; export.ExportFormatOptions = pdfFormat; export.ExportDestinationOptions = dfOptionPDF; myReport.Export(); MessageBox.Show("List PDF Exported Successfully", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information); }
/// //////////////////////////////////////////////////////////////////////// /// EVENTS /// protected void Page_Load(object sender, System.EventArgs e) { // Security check if (!Convert.ToBoolean(Session["sgLFS_APP_VIEW"])) { Response.Redirect("./error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if ((Request.QueryString["target_report"] == null) || (Request.QueryString["format"] == null)) { Response.Redirect("./error_page.aspx?error=" + "Invalid query string in viewer.aspx"); } // Initialize bool empty = false; // Get report data #region Get report data switch (Request.QueryString["target_report"]) { // ... TimesheetMissing case "TimesheetMissing": bool includeSalaried = (Request.QueryString["include_salaried"] == "true") ? true : false; TimesheetMissingReportGateway gateway = new TimesheetMissingReportGateway(); if (Request.QueryString["all_employees"] == "true") { if (Request.QueryString["all_countries"] == "true") { gateway.LoadByFromTo(DateTime.Parse(Request.QueryString["date_from"]), DateTime.Parse(Request.QueryString["date_to"]), Request.QueryString["employee_state"], Request.QueryString["employee_type"], includeSalaried); } else { gateway.LoadByCountryIdFromTo(int.Parse(Request.QueryString["country_id"]), DateTime.Parse(Request.QueryString["date_from"]), DateTime.Parse(Request.QueryString["date_to"]), Request.QueryString["employee_state"], Request.QueryString["employee_type"], includeSalaried); } } else { if (Request.QueryString["all_countries"] == "true") { gateway.LoadByEmployeeIDFromTo(int.Parse(Request.QueryString["employee_id"]), DateTime.Parse(Request.QueryString["date_from"]), DateTime.Parse(Request.QueryString["date_to"]), Request.QueryString["employee_state"], Request.QueryString["employee_type"], includeSalaried); } else { gateway.LoadByCountryIdEmployeeIDFromTo(int.Parse(Request.QueryString["country_id"]), int.Parse(Request.QueryString["employee_id"]), DateTime.Parse(Request.QueryString["date_from"]), DateTime.Parse(Request.QueryString["date_to"]), Request.QueryString["employee_state"], Request.QueryString["employee_type"], includeSalaried); } } if (gateway.Table.Rows.Count > 0) { report = new TimesheetMissingReport(); report.SetDataSource(gateway.Data); if (Request.QueryString["format"] == "pdf") { ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = false; } else { ((Section)report.ReportDefinition.Sections["sPageHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; } } else { empty = true; } break; // rJlinerPrintSearchResults case "rJlinerPrintSearchResults": JlinerNavigatorTDS jlinerNavigatorTDS = (JlinerNavigatorTDS)Session["jlinerNavigatorTDS"]; LiquiForce.LFSLive.BL.CWP.Jliner.JlinerNavigator jlinerNavigator = new LiquiForce.LFSLive.BL.CWP.Jliner.JlinerNavigator(jlinerNavigatorTDS); if (jlinerNavigator.Table.Rows.Count > 0) { report = new LiquiForce.LFSLive.WebUI.CWP.Jliner.rJlinerPrintSearchResults(); report.SetDataSource(jlinerNavigator.Data); ArrayList parameterList = new ArrayList(); parameterList.Add(Request.QueryString["name"]); SetCurrentValuesForParameterField(report, "name", parameterList); parameterList.Clear(); if (Request.QueryString["format"] == "pdf") { // ... Parameters int j; for (int i = 0; i < int.Parse(Request.QueryString["totalColumns"]); i++) { j = i + 1; if (Request.QueryString["header" + j].ToString() == "Hamilton Inspection Number") { parameterList.Add("Hamilton Insp.#"); SetCurrentValuesForParameterField(report, "header" + j, parameterList); parameterList.Clear(); } else { if (Request.QueryString["header" + j].ToString() == "Build / Rebuild") { parameterList.Add("Build / Rebuild #"); SetCurrentValuesForParameterField(report, "header" + j, parameterList); parameterList.Clear(); } else { parameterList.Add(Request.QueryString["header" + j]); SetCurrentValuesForParameterField(report, "header" + j, parameterList); parameterList.Clear(); } } } parameterList.Add(Request.QueryString["comments"]); SetCurrentValuesForParameterField(report, "header39", parameterList); parameterList.Clear(); parameterList.Add(Request.QueryString["history"]); SetCurrentValuesForParameterField(report, "header40", parameterList); parameterList.Clear(); // ... Sections ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetailForExel"]).SectionFormat.EnableSuppress = true; if (int.Parse(Request.QueryString["totalSelectedColumns"]) <= 12) { ((Section)report.ReportDefinition.Sections["sDetail48columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail36columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail24columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail12columns"]).SectionFormat.EnableSuppress = false; } else { if ((int.Parse(Request.QueryString["totalSelectedColumns"]) > 12) && (int.Parse(Request.QueryString["totalSelectedColumns"]) <= 24)) { ((Section)report.ReportDefinition.Sections["sDetail48columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail36columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail24columns"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sDetail12columns"]).SectionFormat.EnableSuppress = true; } else { if ((int.Parse(Request.QueryString["totalSelectedColumns"]) > 24) && (int.Parse(Request.QueryString["totalSelectedColumns"]) <= 36)) { ((Section)report.ReportDefinition.Sections["sDetail48columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail36columns"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sDetail24columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail12columns"]).SectionFormat.EnableSuppress = true; } else { ((Section)report.ReportDefinition.Sections["sDetail48columns"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sDetail36columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail24columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail12columns"]).SectionFormat.EnableSuppress = true; } } } } else { // ... Parameters int j; for (int i = 0; i < int.Parse(Request.QueryString["totalColumns"]); i++) { j = i + 1; if (Request.QueryString["header" + j].ToString() == "Hamilton Inspection Number") { parameterList.Add("Hamilton Insp.#"); SetCurrentValuesForParameterField(report, "header" + j, parameterList); parameterList.Clear(); } else { parameterList.Add(Request.QueryString["header" + j]); SetCurrentValuesForParameterField(report, "header" + j, parameterList); parameterList.Clear(); } } // ... Sections ((Section)report.ReportDefinition.Sections["sReportHeader"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sDetailForExel"]).SectionFormat.EnableSuppress = false; ((Section)report.ReportDefinition.Sections["sDetail48columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail36columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail24columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetail12columns"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetailSectionComments"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetailSectionHistory"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sDetailSeparator"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sPageFooter"]).SectionFormat.EnableSuppress = true; ((Section)report.ReportDefinition.Sections["sTitle"]).SectionFormat.EnableSuppress = true; } // Report format report.PrintOptions.PaperOrientation = PaperOrientation.Landscape; report.PrintOptions.PaperSize = PaperSize.PaperLegal; } else { empty = true; } break; } #endregion if (!empty) { // Configure report // ... Disk options string physicalApplicationPath = Request.PhysicalApplicationPath; if (Request.PhysicalApplicationPath.Substring(Request.PhysicalApplicationPath.Length - 1, 1) != "\\") { physicalApplicationPath += "\\"; } string fName = ""; switch (Request.QueryString["format"]) { case "pdf": fName = physicalApplicationPath + "export\\" + Guid.NewGuid().ToString() + ".pdf"; Session["fName"] = fName; break; case "excel": fName = physicalApplicationPath + "export\\" + Guid.NewGuid().ToString() + ".xls"; Session["fName"] = fName; break; case "word": break; } DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions(); diskOptions.DiskFileName = fName; // ... Export options report.ExportOptions.DestinationOptions = diskOptions; report.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; switch (Request.QueryString["format"]) { case "pdf": report.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; break; case "excel": ExcelFormatOptions excelOptions = new ExcelFormatOptions(); excelOptions.ExcelUseConstantColumnWidth = false; excelOptions.ExcelTabHasColumnHeadings = false; report.ExportOptions.ExportFormatType = ExportFormatType.Excel; report.ExportOptions.FormatOptions = excelOptions; break; case "word": break; } // Export report try { report.Export(); } catch (Exception ex) { Response.Redirect("./error_page.aspx?error=" + ex.Message); } // Preview report Response.Redirect("./viewer2.aspx?target_report=" + Request.QueryString["target_report"] + "&format=" + Request.QueryString["format"], true); } else { Response.Write("<br> No records found for your report."); } }
private void PrintM1M2() { // Border control if (!ShowTitle && !ShowToolBar && !ShowCriteria) { trTopReport.Visible = false; trBottomReport.Visible = false; tdLeftReport.Visible = false; tdRightReport.Visible = false; } // Generate report if (_generateMethod1 == null) { throw new Exception("Generate method 1 is not defined"); } _generateMethod1(); // Generate report if (_generateMethod2 == null) { throw new Exception("Generate method is not defined"); } _generateMethod2(); // Configure & export report for M1 if (_data1.Tables[_table1].Rows.Count > 0) { // ... Path & file name string physicalApplicationPath = Request.PhysicalApplicationPath; if (Request.PhysicalApplicationPath.Substring(Request.PhysicalApplicationPath.Length - 1, 1) != "\\") { physicalApplicationPath += "\\"; } string fileName = ""; switch (hdfFormat1.Value) { case "pdf": fileName = physicalApplicationPath + "export\\" + Guid.NewGuid().ToString() + ".pdf"; break; case "excel": fileName = physicalApplicationPath + "export\\" + Guid.NewGuid().ToString() + ".xls"; break; } DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions(); diskOptions.DiskFileName = fileName; // ... Export options _report1.ExportOptions.DestinationOptions = diskOptions; _report1.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; switch (hdfFormat1.Value) { case "pdf": _report1.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; break; case "excel": ExcelFormatOptions excelOptions = new ExcelFormatOptions(); excelOptions.ExcelUseConstantColumnWidth = false; excelOptions.ExcelTabHasColumnHeadings = false; _report1.ExportOptions.ExportFormatType = ExportFormatType.Excel; _report1.ExportOptions.FormatOptions = excelOptions; break; } // ... Export report try { _report1.Export(); } catch (Exception ex) { Response.Redirect("./../../error_page.aspx?error=" + ex.Message); } // ... Preview report this.ReportFrame = string.Format("./../../new_viewer3.aspx?file_name={0}&report_name={1}&report_format={2}", fileName, "M1 Report", hdfFormat1.Value); } else { this.ReportFrame = "./../../new_viewer2.aspx"; // ... Store state hdfFormat1.Value = "empty"; } // Configure & export report for M2 if (_data2.Tables[_table2].Rows.Count > 0) { // ... Path & file name string physicalApplicationPath = Request.PhysicalApplicationPath; if (Request.PhysicalApplicationPath.Substring(Request.PhysicalApplicationPath.Length - 1, 1) != "\\") { physicalApplicationPath += "\\"; } string fileName = ""; switch (hdfFormat2.Value) { case "pdf": fileName = physicalApplicationPath + "export\\" + Guid.NewGuid().ToString() + ".pdf"; break; case "excel": fileName = physicalApplicationPath + "export\\" + Guid.NewGuid().ToString() + ".xls"; break; } DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions(); diskOptions.DiskFileName = fileName; // ... Export options _report2.ExportOptions.DestinationOptions = diskOptions; _report2.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; switch (hdfFormat2.Value) { case "pdf": _report2.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; break; case "excel": ExcelFormatOptions excelOptions = new ExcelFormatOptions(); excelOptions.ExcelUseConstantColumnWidth = false; excelOptions.ExcelTabHasColumnHeadings = false; _report2.ExportOptions.ExportFormatType = ExportFormatType.Excel; _report2.ExportOptions.FormatOptions = excelOptions; break; } // ... Export report try { _report2.Export(); } catch (Exception ex) { Response.Redirect("./../../error_page.aspx?error=" + ex.Message); } string script = "<script language='javascript'>"; string url = String.Format("./../../new_viewer4.aspx?file_name={0}&report_name={1}&report_format={2}", Server.UrlEncode(fileName), "M2 Report", hdfFormat2.Value); script = script + string.Format("window.open('{0}', '_blank', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=0, height=0')", url); script = script + "</script>"; ScriptManager.RegisterStartupScript(this, this.GetType(), "DownloadAttachment", script, false); } else { this.ReportFrame = "./../../new_viewer2.aspx"; // ... Store state hdfFormat2.Value = "empty"; } }
private void Print() { // Border control if (!ShowTitle && !ShowToolBar && !ShowCriteria) { trTopReport.Visible = false; trBottomReport.Visible = false; tdLeftReport.Visible = false; tdRightReport.Visible = false; } // Generate report if (_generateMethod == null) { throw new Exception("Generate method is not defined"); } _generateMethod(); // Configure & export report if (_data.Tables[_table].Rows.Count > 0) { // ... Path & file name string physicalApplicationPath = Request.PhysicalApplicationPath; if (Request.PhysicalApplicationPath.Substring(Request.PhysicalApplicationPath.Length - 1, 1) != "\\") { physicalApplicationPath += "\\"; } string fileName = ""; switch (hdfFormat.Value) { case "pdf": fileName = physicalApplicationPath + "export\\" + Guid.NewGuid().ToString() + ".pdf"; break; case "excel": fileName = physicalApplicationPath + "export\\" + Guid.NewGuid().ToString() + ".xls"; break; } DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions(); diskOptions.DiskFileName = fileName; // ... Export options _report.ExportOptions.DestinationOptions = diskOptions; _report.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; switch (hdfFormat.Value) { case "pdf": _report.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; break; case "excel": ExcelFormatOptions excelOptions = new ExcelFormatOptions(); excelOptions.ExcelUseConstantColumnWidth = false; excelOptions.ExcelTabHasColumnHeadings = false; _report.ExportOptions.ExportFormatType = ExportFormatType.Excel; _report.ExportOptions.FormatOptions = excelOptions; break; } // ... Export report try { _report.Export(); } catch (Exception ex) { Response.Redirect("./../../error_page.aspx?error=" + ex.Message); } // ... Preview report //title = title.Replace("'", "''"); Title = Title.Replace("'", "%27"); this.ReportFrame = string.Format("./../../new_viewer3.aspx?file_name={0}&report_name={1}&report_format={2}", fileName, Title, hdfFormat.Value); } else { this.ReportFrame = "./../../new_viewer2.aspx"; // ... Store state hdfFormat.Value = "empty"; } }
public void ReportExcel(string key) { try { ReportDocument objRpt = new ReportDocument(); DataSet ds = (DataSet)this.GetDataReport(key); //string reportPath = Application.StartupPath + "\\Reportes\\CROrdenCompraxprov.rpt"; string reportPath = "C:\\Reportes\\CROrdenCompraxprov.rpt"; objRpt.Load(reportPath); DiskFileDestinationOptions crDiskFileDestinationOption = new DiskFileDestinationOptions(); //PdfRtfWordFormatOptions crFormatTypeOption = new PdfRtfWordFormatOptions(); ExcelFormatOptions crFormatTypeOption = new ExcelFormatOptions(); ExportOptions crExportOptions = new ExportOptions(); objRpt.SetDataSource(ds.Tables[0]); string strfolder = "C:\\Reporte\\"; crDiskFileDestinationOption.DiskFileName = strfolder + "DATA.xls"; crExportOptions = objRpt.ExportOptions; crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; crExportOptions.ExportFormatType = ExportFormatType.Excel; crExportOptions.ExportDestinationOptions = crDiskFileDestinationOption; crExportOptions.ExportFormatOptions = crFormatTypeOption; objRpt.Export(); MessageBox.Show("Registros exportados", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { ex.ToString(); } }