private void btnExport_Click(object sender, EventArgs e) { if (printControl1.PrintingSystem != null) { SaveFileDialog dialog = new SaveFileDialog(); dialog.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments); dialog.Filter = "PDF (*.PDF)|*.pdf"; dialog.FilterIndex = 0; if (dialog.ShowDialog() != DialogResult.Cancel) { XtraReport report = GetReport(); string fileName = dialog.FileName; if (!fileName.EndsWith(".pdf")) { fileName = fileName + ".pdf"; } report.ExportToPdf(fileName); MemoryStream stream = new MemoryStream(); report.ExportToPdf(stream); HCMIS.Core.Distribution.Services.PrintLogService.SavePrintLogNoWait(stream, "Archive_Export_" + documentType.EditValue.ToString(), true, Convert.ToInt32(txtDocumentNumber.Text), CurrentContext.UserId, BLL.DateTimeHelper.ServerDateTime); } } }
public async Task <ActionResult> GetReportPdf(int id) { InterimReview interimReview = await db.InterimReviews.FindAsync(id); if (interimReview == null) { return(HttpNotFound()); } XtraReport report = new XtraReport(); string path = Server.MapPath("~/Reports/przeglad.repx"); report.LoadLayout(path); report.Parameters["INTERIMREVIEW_ID"].Value = id; report.CreateDocument(); var stream = new MemoryStream(); report.ExportToPdf(stream); var cd = new System.Net.Mime.ContentDisposition { FileName = "przegląd.pdf", Inline = false, }; Response.AppendHeader("Content-Disposition", cd.ToString()); return(File(stream.GetBuffer(), "application/pdf")); }
public byte[] ExportObject(string KeyMemberName, string ReportDisplayName) { ArrayList keys = new ArrayList { _currentObject.Session.GetKeyValue(_currentObject) }; using (MemoryStream stream = new MemoryStream()) { CriteriaOperator criteria = new InOperator(KeyMemberName, keys); XtraReport report = Report(ReportDisplayName); if (_reportDataSourceHelper != null) { _reportDataSourceHelper.SetupReport(report, null, criteria, true, null, true); } else { _reportV2DataSourceHelper.SetupReport(report, null, criteria, true, null, true); } report.ExportToPdf(stream, new PdfExportOptions { ShowPrintDialogOnOpen = false }); stream.Seek(0, SeekOrigin.Begin); return(stream.ToArray()); } }
public async Task <IActionResult> AllInLineReports(string date1, string date2) { IActionResult response = Unauthorized(); var StartDate = Convert.ToDateTime(date1.Substring(6, 4) + "-" + date1.Substring(3, 2) + "-" + date1.Substring(0, 2) + " 00:00:00"); var EndDate1 = Convert.ToDateTime(date2.Substring(6, 4) + "-" + date2.Substring(3, 2) + "-" + date2.Substring(0, 2) + " 00:00:00"); var fixAssetStraightAll = await _context.FixAssetStraightAlls.Where(p => p.DateInMount >= StartDate && p.DateInMount <= EndDate1).ToListAsync(); //response = Ok(new { data = fixAssetStraightAll }); //return response; XtraReport report = XtraReport.FromFile("reports\\ReportAllInLine.repx"); report.DataSource = fixAssetStraightAll; report.CreateDocument(true); var @out = new MemoryStream(); report.ExportToPdf(@out); @out.Position = 0; response = Ok(new { data = fixAssetStraightAll }); //return response; return(new FileStreamResult(@out, "application/pdf")); }
public async Task <byte[]> ExportResult(LoadResult lr, string format) { XtraReport report = new XtraReport(); var loadedData = lr; report.DataSource = loadedData.data.Cast <Products>(); CreateReport(report, new string[] { "ProductName", "CategoryId", "UnitPrice", "UnitsInStock", "UnitsOnOrder", "Discontinued" }); return(await new TaskFactory().StartNew(() => { report.CreateDocument(); using (MemoryStream fs = new MemoryStream()) { if (format == pdf) { report.ExportToPdf(fs); } else if (format == xlsx) { report.ExportToXlsx(fs); } else if (format == docx) { report.ExportToDocx(fs); } return fs.ToArray(); } })); }
private MemoryStream PrintSn(string snNo, string jobType) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\Modules\Freight\Report\repx\SnBarCode .repx")); DataTable tab = new DataTable(); tab.Columns.Add("SnNo"); DataRow row = tab.NewRow(); if (jobType == "I") { row["SnNo"] = "03-" + snNo + "-00"; } else { row["SnNo"] = "23-" + snNo + "-00"; } tab.Rows.Add(row); rpt.DataSource = tab; System.IO.MemoryStream str = new MemoryStream(); rpt.ExportToPdf(str); return(str); }
private MemoryStream PrintWh_SQ(string refN, string refType, string userId) { System.IO.MemoryStream str = new MemoryStream(); string user = HttpContext.Current.User.Identity.Name; XtraReport rpt = new XtraReport(); string path = SafeValue.SafeString(ConnectSql.ExecuteScalar(string.Format("select path from sys_rpt where name='{0}'", refType))); if (path.Length == 0) { return(str); } //rpt.LoadLayout(Server.MapPath(@"~\ReportWarehouse\repx\po.repx")); rpt.LoadLayout(Server.MapPath(path)); string strsql = string.Format(@"exec proc_PrintWh_Po '{0}','{1}','{2}','{3}','{4}'", refN, "", refType, userId, ""); DataSet ds_temp = ConnectSql.GetDataSet(strsql); DataTable Mast = ds_temp.Tables[0].Copy(); Mast.TableName = "Mast"; DataTable Detail = ds_temp.Tables[1].Copy(); Detail.TableName = "Detail"; DataSet set = new DataSet(); set.Tables.Add(Mast); set.Tables.Add(Detail); set.Relations.Add("Rela", Mast.Columns["Relation"], Detail.Columns["Relation"]); rpt.DataSource = set; rpt.CreateDocument(); rpt.ExportToPdf(str); return(str); }
private MemoryStream PrintInventoryBalance(string orderNo, string jobType, string date1, string date2) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\Modules\Tpt\Report\repx\InventoryBalance.repx")); DataSet set = null; if (date1.Length > 0) { string[] s1 = date1.Split('/'); DateTime d1 = new DateTime(SafeValue.SafeInt(s1[2], 0), SafeValue.SafeInt(s1[1], 0), SafeValue.SafeInt(s1[0], 0)); DateTime d2 = DateTime.Today; if (date1 != null) { set = DocPrint.PrintInventoryBalance(orderNo, d1); } } rpt.DataSource = set; System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
private MemoryStream PrintStockTallySheet(string orderNo, string jobType, string date1, string date2) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\StockTallySheet.repx")); DataSet set = null; if (date1.Length > 0 && date2.Length > 0) { string[] s1 = date1.Split('/'); string[] s2 = date2.Split('/'); DateTime d1 = new DateTime(SafeValue.SafeInt(s1[2], 0), SafeValue.SafeInt(s1[1], 0), SafeValue.SafeInt(s1[0], 0)); DateTime d2 = new DateTime(SafeValue.SafeInt(s2[2], 0), SafeValue.SafeInt(s2[1], 0), SafeValue.SafeInt(s2[0], 0)); if (date1 != null && date2 != null) { set = DocPrint.PrintStockTallySheet(orderNo, d1, d2); } } else { set = DocPrint.PrintJobStockTallySheet(orderNo, jobType); } rpt.DataSource = set; System.IO.MemoryStream str = new MemoryStream(); rpt.ExportToPdf(str); return(str); }
private MemoryStream PrintClaims(string driver, string dt_from, string dt_to) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\Claims.repx")); string sql_where = string.Format("and DATEDIFF(d,ToDate,'{0}')<=0 and DATEDIFF(d,ToDate,'{1}')>=0", dt_from, dt_to); if (driver.Trim().Length > 0) { sql_where += " and det2.DriverCode='" + driver + "'"; } string sql = string.Format(@"select det2.Id,det2.JobNo,Det1.ContainerNo,det1.ContainerType,det2.TowheadCode,det2.ChessisCode,det2.DriverCode, det2.ToCode,det2.ToDate,det2.ToTime,det2.FromCode,det2.FromDate,det2.FromTime,convert(varchar(10),ToDate,103) as Date,FromTime+'-'+ToTime Time, isnull(det2.Charge1,0) as Charge1,isnull(det2.Charge2,0) as Charge2,isnull(det2.Charge3,0) as Charge3,isnull(det2.Charge4,0) as Charge4,isnull(det2.Charge5,0) as Charge5, isnull(det2.Charge6,0) as Charge6,isnull(det2.Charge7,0) as Charge7,isnull(det2.Charge8,0) as Charge8,isnull(det2.Charge9,0) as Charge9, isnull(Charge1,0)+isnull(Charge2,0)+isnull(Charge3,0)+isnull(Charge4,0)+isnull(Charge5,0)+isnull(Charge6,0)+isnull(Charge7,0)+isnull(Charge8,0)+isnull(Charge9,0) as TotalCharge from ctm_jobdet2 as det2 left outer join ctm_jobdet1 as det1 on det2.det1Id=det1.Id where det2.Statuscode='C' {0}", sql_where); DataTable dt = ConnectSql.GetTab(sql); rpt.DataSource = dt; System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
private MemoryStream PrintTallySheetIndented(string orderNo, string jobType) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\TallySheet.repx")); DataSet set = DocPrint.PrintTallySheet(orderNo, jobType, "Indented"); DataTable Mast = set.Tables[0].Copy(); Mast.TableName = "Mast"; DataTable Detail = set.Tables[1].Copy(); Detail.TableName = "Details"; //if (Detail.Rows.Count > 0) //{ // DevExpress.XtraReports.UI.DetailReportBand details = rpt.Report.Bands["DetailReport"] as DevExpress.XtraReports.UI.DetailReportBand; // if (details != null) // { // DevExpress.XtraReports.UI.DetailBand gridLine_sub = details.Bands["Detail"] as DevExpress.XtraReports.UI.DetailBand; // DevExpress.XtraReports.UI.XRSubreport subReport_Line = new XRSubreport(); // subReport_Line.Name = "GridLine_sub"; // gridLine_sub.Controls.Add(subReport_Line); // XtraReport rpt_Inv = new XtraReport(); // rpt_Inv.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\TallySheet_sub.repx")); // subReport_Line.ReportSource = rpt_Inv; // rpt_Inv.DataSource = Detail; // } //} rpt.DataSource = set; System.IO.MemoryStream str = new MemoryStream(); rpt.ExportToPdf(str); return(str); }
private Boolean Crear_Pdf_en_TMP(tb_Comprobante_Info InfoCbteT, string Ruta_File) { try { string msg = ""; XtraReport Reporte = new XtraReport(); tb_Empresa_Bus EmB = new tb_Empresa_Bus(); Rpt_Ride_bus Rpt_Ride_Bus = new Rpt_Ride_bus(listEmpr); Reporte = Rpt_Ride_Bus.Optener_reporte(InfoCbteT, ref msg); //pdf Stream FileBinary; FileBinary = new FileStream(Ruta_File + "\\" + InfoCbteT.IdComprobante + ".pdf", FileMode.Create); DevExpress.XtraPrinting.PdfExportOptions Optione = new DevExpress.XtraPrinting.PdfExportOptions(); Reporte.ExportToPdf(FileBinary, Optione); FileBinary.Close(); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); BusSisLog.Log_Error(ex.Message.ToString(), eTipoError.ERROR, this.ToString()); return(false); } }
public ActionResult Descargar(string tipo, string reportId, string primarykey) { var service = new DocumentosUsuarioService(MarfilEntities.ConnectToSqlServer(ContextService.BaseDatos)); var tipoDocumento = (TipoDocumentoImpresion)Enum.Parse(typeof(TipoDocumentoImpresion), tipo); Guid usuario = ContextService.Id; string name = reportId; ViewBag.Tipo = (int)tipoDocumento; ViewBag.Usuario = usuario.ToString(); var model = new DesignModel { Url = reportId, Report = service.GetDocumentoParaImprimir(tipoDocumento, usuario, name)?.Datos, DataSource = FDocumentosDatasourceReport.CreateReport(tipoDocumento, ContextService, primarykey).DataSource, Name = name }; var report = new XtraReport(); using (var ms = new MemoryStream(model.Report)) { report.LoadLayout(ms); report.DataSource = model.DataSource; report.Name = model.Name; using (var stream = new MemoryStream()) { report.ExportToPdf(stream); return(File(stream.GetBuffer(), "application/pdf")); } } }
private MemoryStream ExportReportToStream(XtraReport xReport) { var str = new MemoryStream(); xReport.ExportToPdf(str); return(str); }
private async Task ExportResult(string format, DataSourceLoadOptionsBase dataOptions, HttpContext context) { XtraReport report = new XtraReport(); dataOptions.Skip = 0; dataOptions.Take = 0; var loadedData = DataSourceLoader.Load(await weatherForecastService.GetForecastAsync(), dataOptions); report.DataSource = loadedData.data.Cast <WeatherForecast>(); ReportHelper.CreateReport(report, new string[] { "TemperatureC", "TemperatureF", "Summary", "Date" }); await new TaskFactory().StartNew(() => { report.CreateDocument(); using (MemoryStream fs = new MemoryStream()) { if (format == pdf) { report.ExportToPdf(fs); } else if (format == xlsx) { report.ExportToXlsx(fs); } else if (format == docx) { report.ExportToDocx(fs); } context.Response.Clear(); context.Response.Headers.Append("Content-Type", "application/" + format); context.Response.Headers.Append("Content-Transfer-Encoding", "binary"); context.Response.Headers.Append("Content-Disposition", "attachment; filename=ExportedDocument." + format); context.Response.Body.WriteAsync(fs.ToArray(), 0, fs.ToArray().Length); return(context.Response.CompleteAsync()); } }); }
private void SetReportPreview(bool preview, XtraReport report, bool createDocument = true) { if (createDocument) { report.CreateDocument(); } //report.ExportToPdf("");//Shranjevanje poročila na disk if (preview) { WebDocumentViewer.OpenReport(report); } else { using (MemoryStream ms = new MemoryStream()) { PdfExportOptions opts = new PdfExportOptions(); opts.ShowPrintDialogOnOpen = true; report.ExportToPdf(ms, opts); WriteDocumentToResponse(ms.ToArray(), "pdf", true, "Report_" + DateTime.Now.ToString("dd_MM_YYYY-HH_mm_ss_") + DateTime.Now.TimeOfDay.TotalMilliseconds.ToString()); } } }
public void ExportReport(XtraReport report, string fileName, string fileType, bool inline) { MemoryStream stream = new MemoryStream(); Response.Clear(); if (fileType == "xls") { report.ExportToXls(stream); } if (fileType == "pdf") { report.ExportToPdf(stream); } if (fileType == "rtf") { report.ExportToRtf(stream); } if (fileType == "csv") { report.ExportToCsv(stream); } Response.ContentType = "application/" + fileType; Response.AddHeader("Accept-Header", stream.Length.ToString()); Response.AddHeader("Content-Disposition", (inline ? "Inline" : "Attachment") + "; filename=" + fileName + "." + fileType); Response.AddHeader("Content-Length", stream.Length.ToString()); //Response.ContentEncoding = System.Text.Encoding.Default; Response.BinaryWrite(stream.ToArray()); Response.End(); }
private Boolean Descargar_PDF_RIDE(tb_Comprobante_Info InfoCbteT, string Ruta_File, string OpcionNombreDes) { try { string msg = ""; string nombreArchivo = ""; XtraReport Reporte = new XtraReport(); Reporte = Rpt_Ride_Bus.Optener_reporte(InfoCbteT, ref msg); Stream FileBinary; if (OpcionNombreDes == "claveAcceso") { XmlDocument xmlOrigenCdata = new XmlDocument(); xmlOrigenCdata.LoadXml(InfoCbteT.s_XML); string claveAcceso = xmlOrigenCdata.GetElementsByTagName("comprobante")[0].InnerXml.Replace("<![CDATA[", "").Replace("]]>", ""); xmlOrigenCdata.LoadXml(claveAcceso); nombreArchivo = xmlOrigenCdata.GetElementsByTagName("claveAcceso")[0].InnerText; } else { nombreArchivo = InfoCbteT.Nom_emisor + "_" + InfoCbteT.IdComprobante; } FileBinary = new FileStream(Ruta_File + "\\" + nombreArchivo + ".pdf", FileMode.Create); DevExpress.XtraPrinting.PdfExportOptions Optione = new DevExpress.XtraPrinting.PdfExportOptions(); Reporte.ExportToPdf(FileBinary, Optione); FileBinary.Close(); return(true); } catch (Exception ex) { return(false); } }
private MemoryStream PrintVoucher(string billNo) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\ReportFreightSea\repx\Account\Voucher.repx")); DataSet set = AccountFreightPrint.PrintVoucher(billNo); DevExpress.XtraReports.UI.GroupFooterBand groupFooter1 = rpt.Report.Bands["GroupFooter1"] as DevExpress.XtraReports.UI.GroupFooterBand; DevExpress.XtraReports.UI.XRSubreport subReport1 = new XRSubreport(); subReport1.Name = "groupFooter1"; groupFooter1.Controls.Add(subReport1); XtraReport rpt1 = new XtraReport(); rpt1.LoadLayout(Server.MapPath(@"~\ReportFreightSea\repx\Account\Voucher_detail.repx")); subReport1.ReportSource = rpt1; rpt1.DataSource = set; DevExpress.XtraReports.UI.GroupFooterBand groupFooter2 = rpt.Report.Bands["GroupFooter2"] as DevExpress.XtraReports.UI.GroupFooterBand; DevExpress.XtraReports.UI.XRSubreport subReport2 = new XRSubreport(); subReport2.Name = "groupFooter2"; groupFooter2.Controls.Add(subReport2); XtraReport rpt2 = new XtraReport(); rpt2.LoadLayout(Server.MapPath(@"~\ReportFreightSea\repx\Account\Voucher_detail.repx")); subReport2.ReportSource = rpt2; rpt2.DataSource = set; System.IO.MemoryStream str = new MemoryStream(); rpt.ExportToPdf(str); return(str); }
private MemoryStream PrintWhFCL(string billType, string date1, string date2, string userName) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\ReportWarehouse\repx\FCL.repx")); if (date1.IndexOf("/") != -1 && date2.IndexOf("/") != -1) { string[] s1 = date1.Split('/'); string[] s2 = date2.Split('/'); DateTime d1 = new DateTime(SafeValue.SafeInt(s1[2], 0), SafeValue.SafeInt(s1[1], 0), SafeValue.SafeInt(s1[0], 0)); DateTime d2 = new DateTime(SafeValue.SafeInt(s2[2], 0), SafeValue.SafeInt(s2[1], 0), SafeValue.SafeInt(s2[0], 0)); rpt.DataSource = WarehouseRptPrint.dsFCL(billType, d1, d2, userName); } System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
protected void Page_Load(object sender, EventArgs e) { string reportDataHandle = Request.QueryString["reportContainerHandle"]; ReportsModuleV2 module = ReportsModuleV2.FindReportsModule(ApplicationReportObjectSpaceProvider.ContextApplication.Modules); if (!String.IsNullOrEmpty(reportDataHandle) && module != null) { XtraReport report = null; try { report = ReportDataProvider.ReportsStorage.GetReportContainerByHandle(reportDataHandle).Report; module.ReportsDataSourceHelper.SetupBeforePrint(report, null, null, false, null, false); using (MemoryStream ms = new MemoryStream()) { report.CreateDocument(); PdfExportOptions options = new PdfExportOptions(); options.ShowPrintDialogOnOpen = true; report.ExportToPdf(ms, options); ms.Seek(0, SeekOrigin.Begin); byte[] reportContent = ms.ToArray(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "attachment; filename=MyFileName.pdf"); Response.Clear(); Response.OutputStream.Write(reportContent, 0, reportContent.Length); Response.End(); } } finally { if (report != null) { report.Dispose(); } } } }
/// <summary> /// 导出PDF /// </summary> /// <param name="reportClass"></param> /// <param name="filePath"></param> private void ExportToPdf(XtraReport reportClass, string filePath) { if (reportClass == null) { return; } reportClass.ExportToPdf(filePath); }
public PDFActionResult(XtraReport report) { using (MemoryStream stream = new MemoryStream()) { report.CreateDocument(); report.ExportToPdf(stream); _byteArray = stream.ToArray(); } }
public void WritePdfToResponse(HttpResponseBase Response, string fileName, string type) { report.CreateDocument(false); using (MemoryStream ms = new MemoryStream()) { report.ExportToPdf(ms); ms.Seek(0, SeekOrigin.Begin); WriteResponse(Response, ms.ToArray(), type, fileName); } }
public async Task <ActionResult> GetReportPdf(int id) { ReadingOfFiscalMemory readerFiscalMemory = await db.ReadingOfFiscalMemories.FindAsync(id); if (readerFiscalMemory == null) { return(HttpNotFound()); } XtraReport reportService = new XtraReport(); string pathToReportService = Server.MapPath("~/Reports/odczyt_page1.repx"); reportService.LoadLayout(pathToReportService); reportService.Parameters["ID"].Value = id; reportService.CreateDocument(); XtraReport reportCustomer = new XtraReport(); string pathToReportCustomer = Server.MapPath("~/Reports/odczyt_page2.repx"); reportCustomer.LoadLayout(pathToReportCustomer); reportCustomer.Parameters["ID"].Value = id; reportCustomer.CreateDocument(); XtraReport unregisterDevice = new XtraReport(); string pathToUnregisterDevice = Server.MapPath("~/Reports/wyrejestrowanie_kasy.repx"); unregisterDevice.LoadLayout(pathToUnregisterDevice); unregisterDevice.Parameters["ID"].Value = id; unregisterDevice.Parameters["MODULE_ID"].Value = readerFiscalMemory.ModuleId; unregisterDevice.CreateDocument(); XtraReport applicationForReading = new XtraReport(); string pathToApplicationForReading = Server.MapPath("~/Reports/wniosek_dokonanie_odczytu.repx"); applicationForReading.LoadLayout(pathToApplicationForReading); applicationForReading.Parameters["ID"].Value = id; applicationForReading.Parameters["MODULE_ID"].Value = readerFiscalMemory.ModuleId; applicationForReading.CreateDocument(); reportService.Pages.AddRange(reportCustomer.Pages); reportService.Pages.AddRange(unregisterDevice.Pages); reportService.Pages.AddRange(applicationForReading.Pages); reportService.PrintingSystem.ContinuousPageNumbering = false; var stream = new MemoryStream(); reportService.ExportToPdf(stream); var cd = new System.Net.Mime.ContentDisposition { FileName = "odczyt.pdf", Inline = false, }; Response.AppendHeader("Content-Disposition", cd.ToString()); return(File(stream.GetBuffer(), "application/pdf")); }
private static void ExportReport(IReportDataV2 reportData, IObjectSpaceProvider objectSpaceProvider) { XtraReport report = ReportDataProvider.ReportsStorage.LoadReport(reportData); MyReportDataSourceHelper reportDataSourceHelper = new MyReportDataSourceHelper(objectSpaceProvider); ReportDataProvider.ReportObjectSpaceProvider = new MyReportObjectSpaceProvider(objectSpaceProvider); reportDataSourceHelper.SetupBeforePrint(report); report.ExportToPdf("test.pdf"); }
private MemoryStream PrintJobOrder(string no, string userName) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\ReportTpt\repx\JobOrder.repx")); rpt.DataSource = TptDocPrint.PrintJobOrder(no, "TPT"); System.IO.MemoryStream str = new MemoryStream(); rpt.ExportToPdf(str); return(str); }
private void btnPrint_Click(object sender, EventArgs e) { if (printControl1.PrintingSystem != null) { XtraReport report = GetReport(); MemoryStream stream = new MemoryStream(); report.ExportToPdf(stream); report.PrintDialog(); } }
private MemoryStream PrintPayrollSilp(string master, string dateTime1, string dateTime2, string person) { string dateFrom = Helper.Safe.SafeDateStr(dateTime1); string dateTo = Helper.Safe.SafeDateStr(dateTime2); DateTime from = DateTime.ParseExact(dateFrom, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); DateTime to = DateTime.ParseExact(dateTo, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); string user = HttpContext.Current.User.Identity.Name; XtraReport rpt = new XtraReport(); string role = SafeValue.SafeString(ConnectSql_mb.ExecuteScalar(string.Format(@"select HrRole from Hr_Person where Id={0}", person))); if (role.ToLower() == "driver") { rpt.LoadLayout(Server.MapPath(@"~\Modules\Hr\Report\repx\PayrollSlip_driver.repx")); } else { rpt.LoadLayout(Server.MapPath(@"~\Modules\Hr\Report\repx\PayrollSlip.repx")); } DataSet set = HrPrint.PrintPaySlip(master, from, to); DataTable tab_mast = set.Tables[0]; DataTable tab_det = set.Tables[1]; DataTable tab_det1 = set.Tables[2]; if (tab_det.Rows.Count > 0) { DevExpress.XtraReports.UI.PageHeaderBand header = rpt.Report.Bands["PageHeader"] as DevExpress.XtraReports.UI.PageHeaderBand; if (header != null) { DevExpress.XtraReports.UI.XRSubreport subReport_Ot = header.FindControl("Overtime_sub", true) as DevExpress.XtraReports.UI.XRSubreport; subReport_Ot.Name = "Overtime_sub"; XtraReport rpt_Inv = new XtraReport(); rpt_Inv.LoadLayout(Server.MapPath(@"~\Modules\Hr\Report\repx\PayrollSlip_sub.repx")); subReport_Ot.ReportSource = rpt_Inv; rpt_Inv.DataSource = tab_det; } } if (tab_det1.Rows.Count > 0) { DevExpress.XtraReports.UI.PageHeaderBand header = rpt.Report.Bands["PageHeader"] as DevExpress.XtraReports.UI.PageHeaderBand; if (header != null) { DevExpress.XtraReports.UI.XRSubreport subReport_Ot = header.FindControl("Overtime_sub2", true) as DevExpress.XtraReports.UI.XRSubreport; subReport_Ot.Name = "Overtime_sub2"; XtraReport rpt_Inv = new XtraReport(); rpt_Inv.LoadLayout(Server.MapPath(@"~\Modules\Hr\Report\repx\PayrollSlip_sub.repx")); subReport_Ot.ReportSource = rpt_Inv; rpt_Inv.DataSource = tab_det1; } } rpt.DataSource = set; System.IO.MemoryStream str = new MemoryStream(); rpt.ExportToPdf(str); return(str); }
private MemoryStream PrintDrNoteA4(string billNo) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\ReportFreightSea\repx\Account\Invoice_A4.repx")); rpt.DataSource = AccountFreightPrint.PrintInvoice(billNo, "DN"); System.IO.MemoryStream str = new MemoryStream(); rpt.ExportToPdf(str); return(str); }
protected void Page_Load(object sender, EventArgs e) { string Type=Request.Form.Get("type"); //Section "Восстановить у пользователя" if (Type == DOWNLOAD_FILE_RECOVER_USER) { if (Request.Form.Get("dataBlockId") != null) { int dataBlockId = Convert.ToInt32(Request.Form.Get("dataBlockId")); string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"]; DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]); dataBlock.OpenConnection(); byte[] fileBytes = dataBlock.GetDataBlock_BytesArray(dataBlockId); string fileName = dataBlock.GetDataBlock_FileName(dataBlockId); dataBlock.CloseConnection(); Response.Clear(); Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", fileName)); Response.AddHeader("Content-Length", fileBytes.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.OutputStream.Write(fileBytes, 0, fileBytes.Length); Response.End(); return; } } //Section "PLF Файлы" if (Type == GET_PLF_REPORT) { string CardID=Request.Form.Get("CardID"); string PLFID=Request.Form.Get("PLFID"); string UserName = Request.Form.Get("UserName"); string Format = Request.Form.Get("Format"); string ReportType = Request.Form.Get("ReportType"); if (string.IsNullOrEmpty(ReportType)) { ReportType = "Полный отчет"; } int dataBlockId = int.Parse(PLFID); List<int> dataBlockIDS = new List<int>(); dataBlockIDS.Add(dataBlockId); int cardID = int.Parse(CardID); string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"]; BLL.DataBlock dataBlock = new BLL.DataBlock(connectionString, ConfigurationManager.AppSettings["language"]); dataBlock.OpenConnection(); DateTime from = new DateTime(); from = dataBlock.plfUnitInfo.Get_START_PERIOD(dataBlockId); DateTime to = new DateTime(); to = dataBlock.plfUnitInfo.Get_END_PERIOD(dataBlockId); string vehicle = dataBlock.plfUnitInfo.Get_VEHICLE(dataBlockId); string deviceID = dataBlock.plfUnitInfo.Get_ID_DEVICE(dataBlockId); DataSet dataset = new DataSet(); int userId = dataBlock.usersTable.Get_UserID_byName(UserName); List<PLFUnit.PLFRecord> records = new List<PLFUnit.PLFRecord>(); dataset = ReportDataSetLoader.Get_PLF_ALLData(dataBlockIDS, new DateTime(from.Year, from.Month, from.Day), new DateTime(to.Year, to.Month, to.Day), cardID, userId, ref records); dataBlock.CloseConnection(); //gets table PlfHeader_1 DataTable dt = dataset.Tables[0]; //gets the first row DataRow dr = dt.Rows[0]; string driverName = dr["Имя водителя"].ToString(); //load needed template string path = HttpContext.Current.Server.MapPath("~/templates_plf") + "\\"; XtraReport report = new XtraReport(); report.LoadLayout(path + ReportType+".repx"); report.DataSource = dataset; MemoryStream reportStream = new MemoryStream(); switch (Format) { case "html": report.ExportToHtml(reportStream); break; case "pdf": report.ExportToPdf(reportStream); break; case "rtf": report.ExportToRtf(reportStream); break; case "png": report.ExportToImage(reportStream,ImageFormat.Png); break; } Response.Clear(); Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + driverName + " " + new DateTime(from.Year, from.Month, from.Day).ToString("dd_MM_yyyy") + "-" + new DateTime(to.Year, to.Month, to.Day).ToString("dd_MM_yyyy") + "." + Format)); Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString()); Response.ContentType = "application/octet-stream"; Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length); Response.End(); return; } if (Type == GET_PLF_REPORT_FOR_PERIOD) { string CardID = Request.Form.Get("CardID"); string StartDate = Request.Form.Get("StartDate"); string EndDate = Request.Form.Get("EndDate"); string UserName = Request.Form.Get("UserName"); string Format = Request.Form.Get("Format"); string ReportType = Request.Form.Get("ReportType"); if (string.IsNullOrEmpty(ReportType)) { ReportType = "Полный отчет"; } int cardID = int.Parse(CardID); string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"]; BLL.DataBlock dataBlock = new BLL.DataBlock(connectionString, ConfigurationManager.AppSettings["language"]); dataBlock.OpenConnection(); DateTime from = DateTime.Parse(StartDate); DateTime to = DateTime.Parse(EndDate); DataSet dataset = new DataSet(); List<int> dataBlockIDS = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardID); int userId = dataBlock.usersTable.Get_UserID_byName(UserName); List<PLFUnit.PLFRecord> records = new List<PLFUnit.PLFRecord>(); dataset = ReportDataSetLoader.Get_PLF_ALLData(dataBlockIDS, new DateTime(from.Year, from.Month, from.Day), new DateTime(to.Year, to.Month, to.Day), cardID, userId, ref records); dataBlock.CloseConnection(); //gets table PlfHeader_1 DataTable dt = dataset.Tables[0]; //gets the first row DataRow dr = dt.Rows[0]; string driverName = dr["Имя водителя"].ToString(); //load needed template string path = HttpContext.Current.Server.MapPath("~/templates_plf") + "\\"; XtraReport report = new XtraReport(); report.LoadLayout(path + ReportType + ".repx"); report.DataSource = dataset; MemoryStream reportStream = new MemoryStream(); switch (Format) { case "html": report.ExportToHtml(reportStream); break; case "pdf": report.ExportToPdf(reportStream); break; case "rtf": report.ExportToRtf(reportStream); break; case "png": report.ExportToImage(reportStream, ImageFormat.Png); break; } Response.Clear(); Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + driverName + " " + new DateTime(from.Year, from.Month, from.Day).ToString("dd_MM_yyyy") + "-" + new DateTime(to.Year, to.Month, to.Day).ToString("dd_MM_yyyy") + "." + Format)); Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString()); Response.ContentType = "application/octet-stream"; Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length); Response.End(); return; } //Section "Транспортные средства" if (Type == GET_DDD_REPORT) { string DataBlockID = Request.Form.Get("DataBlockID"); string UserName = Request.Form.Get("UserName"); string Format = Request.Form.Get("Format"); string ReportType = Request.Form.Get("ReportType"); if (string.IsNullOrEmpty(ReportType)) { ReportType = "Полный отчет"; } int dataBlockId = int.Parse(DataBlockID); List<int> dataBlockIDS = new List<int>(); dataBlockIDS.Add(dataBlockId); string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"]; DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]); dataBlock.OpenConnection(); DataSet dataset = new DataSet(); string VIN = dataBlock.vehicleUnitInfo.Get_VehicleOverview_IdentificationNumber(dataBlockId).ToString(); string RegNumb = dataBlock.vehicleUnitInfo.Get_VehicleOverview_RegistrationIdentification(dataBlockId).vehicleRegistrationNumber.ToString(); int vehicleId = dataBlock.vehiclesTables.GetVehicleId_byVinRegNumbers(VIN, RegNumb); List<DateTime> vehsCardPeriod = dataBlock.vehicleUnitInfo.Get_StartEndPeriod(dataBlockId); int userId = dataBlock.usersTable.Get_UserID_byName(UserName); dataset = ReportDataSetLoader.Get_Vehicle_ALLDate(vehicleId, dataBlockIDS, vehsCardPeriod[0], vehsCardPeriod[1], userId); dataBlock.CloseConnection(); //load needed template string path = HttpContext.Current.Server.MapPath("~/templates_ddd") + "\\"; XtraReport report = new XtraReport(); report.LoadLayout(path + ReportType + ".repx"); report.DataSource = dataset; MemoryStream reportStream = new MemoryStream(); switch (Format) { case "html": report.ExportToHtml(reportStream); break; case "pdf": report.ExportToPdf(reportStream); break; case "rtf": report.ExportToRtf(reportStream); break; case "png": report.ExportToImage(reportStream, ImageFormat.Png); break; } Response.Clear(); Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + VIN + "_" + RegNumb + " " + vehsCardPeriod[0].ToString("dd_MM_yyyy") + "-" + vehsCardPeriod[1].ToString("dd_MM_yyyy") + "." + Format)); Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString()); Response.ContentType = "application/octet-stream"; Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length); Response.End(); return; } //Section "Транспортные средства" if (Type == GET_DDD_REPORT_FOR_PERIOD) { string CardID = Request.Form.Get("CardID"); string StartDate = Request.Form.Get("StartDate"); string EndDate = Request.Form.Get("EndDate"); string UserName = Request.Form.Get("UserName"); string Format = Request.Form.Get("Format"); string ReportType = Request.Form.Get("ReportType"); if (string.IsNullOrEmpty(ReportType)) { ReportType = "Полный отчет"; } string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"]; DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]); dataBlock.OpenConnection(); DataSet dataset = new DataSet(); int cardId = int.Parse(CardID); string VIN = dataBlock.vehiclesTables.GetVehicleVin(cardId); string RegNumb = dataBlock.vehiclesTables.GetVehicleGOSNUM(cardId); int vehicleId = dataBlock.vehiclesTables.GetVehicle_byCardId(cardId); List<int> dataBlockIDS = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId); int userId = dataBlock.usersTable.Get_UserID_byName(UserName); DateTime from = DateTime.Parse(StartDate); DateTime to = DateTime.Parse(EndDate); dataset = ReportDataSetLoader.Get_Vehicle_ALLDate(vehicleId, dataBlockIDS, from, to, userId); dataBlock.CloseConnection(); //load needed template string path = HttpContext.Current.Server.MapPath("~/templates_ddd") + "\\"; XtraReport report = new XtraReport(); report.LoadLayout(path + ReportType + ".repx"); report.DataSource = dataset; MemoryStream reportStream = new MemoryStream(); switch (Format) { case "html": report.ExportToHtml(reportStream); break; case "pdf": report.ExportToPdf(reportStream); break; case "rtf": report.ExportToRtf(reportStream); break; case "png": report.ExportToImage(reportStream, ImageFormat.Png); break; } Response.Clear(); Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + VIN + "_" + RegNumb + " " + from.ToString("dd_MM_yyyy") + "-" + to.ToString("dd_MM_yyyy") + "." + Format)); Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString()); Response.ContentType = "application/octet-stream"; Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length); Response.End(); return; } }
/// <summary> /// 导出PDF /// </summary> /// <param name="reportClass"></param> /// <param name="filePath"></param> private void ExportToPdf(XtraReport reportClass, string filePath) { if (reportClass == null) return; reportClass.ExportToPdf(filePath); }