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 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); }
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 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); }
public void WritePdfToResponse(HttpResponseBase Response, string fileName, string type) { report.CreateDocument(false); using (MemoryStream ms = new MemoryStream()) { //report.ExportToPdf(ms);// //report.ExportToXlsx(ms); report.ExportToXls(ms); ms.Seek(0, SeekOrigin.Begin); WriteResponse(Response, ms.ToArray(), type, fileName); } }
private MemoryStream PrintBillList(string billType, string party, string date1, string date2, string sortFiled, string userName, string refType) { XtraReport rpt = new XtraReport(); if (billType == "VO" || billType == "PL") { rpt.LoadLayout(Server.MapPath(@"~\ReportFreightSea\ReportRepx\Account\VoucherList.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 = SeaFreightRptPrint.dsVoucherByDate(billType, party, d1, d2, sortFiled, userName, refType); } else { rpt.DataSource = SeaFreightRptPrint.dsVoucherByNo(billType, party, date1, date2, sortFiled, userName, refType); } } else { rpt.LoadLayout(Server.MapPath(@"~\ReportFreightSea\ReportRepx\Account\InvoiceList.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 = SeaFreightRptPrint.dsInvoiceByDate(billType, party, d1, d2, sortFiled, userName, refType); } else { rpt.DataSource = SeaFreightRptPrint.dsInvoiceByNo(billType, party, date1, date2, sortFiled, userName, refType); } } System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
public static void OutputReportToSaveInXls(string fileName, XtraReport xtraReport, System.Web.HttpResponse response, XlsExportOptions xlsOptions) { using (var ms = new MemoryStream()) { xtraReport.ExportToXls(ms, xlsOptions); ms.Seek(0, SeekOrigin.Begin); byte[] report = ms.ToArray(); response.Buffer = true; response.Clear(); response.ContentType = "application/vnd.ms-excel"; response.AddHeader("content-disposition", "attachment; filename=" + fileName + "_" + DateTime.Now.ToString("dd_MM_yyyy", new System.Globalization.CultureInfo("en-US")) + "." + "xls"); response.BinaryWrite(report); response.Flush(); } }
private MemoryStream PrintSo(string refId) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\ReportAir\repx\Export\rptSo.repx")); rpt.DataSource = AirFreightDocPrint.dsSo(refId); System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
private MemoryStream PrintLoadPlan(string RefN, string reportType) { string user = HttpContext.Current.User.Identity.Name; XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\ReportAir\repx\Export\rptLoadPlan.repx")); //rpt.DataSource = AirFreightDocPrint.dsLoadPlan(RefN); System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
private MemoryStream PrintManifest(string ImportN) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\ReportAir\repx\Import\rptImpManifest.repx")); rpt.DataSource = AirFreightDocPrint.PrintManifest(ImportN); System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
private MemoryStream PrintIncentiveMonthly(string driver, string dt_from, string dt_to) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\IncentiveMonthly.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 t_date = ""; try { t_date = dt_from.Substring(6, 2) + "/" + dt_from.Substring(4, 2) + "/" + dt_from.Substring(0, 4); t_date += " - " + dt_to.Substring(6, 2) + "/" + dt_to.Substring(4, 2) + "/" + dt_to.Substring(0, 4); } catch (Exception ex) { } string sql = string.Format(@"select temp.*,driver.TowheaderCode as TowheadCode,Incentive1+Incentive2+Incentive3+Incentive4 as TotalIncentive,'{3}' as Date from ( select DriverCode,sum(isnull(det2.Incentive1,0)) as Incentive1,sum(isnull(det2.Incentive2,0)) as Incentive2, sum(isnull(det2.Incentive3,0)) as Incentive3,sum(isnull(det2.Incentive4,0)) as Incentive4 from ctm_jobdet2 as det2 where det2.Statuscode='C' and DATEDIFF(d,det2.ToDate,'{0}')<=0 and DATEDIFF(d,det2.ToDate,'{1}')>=0 {2} group by DriverCode ) as temp left outer join CTM_Driver as driver on temp.DriverCode=driver.Code ", dt_from, dt_to, sql_where, t_date); DataTable dt = ConnectSql.GetTab(sql); dt.TableName = "Detail"; rpt.DataSource = dt; System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
private MemoryStream PrintMovementDetail(string no, string sku) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\MovementDetail.repx")); rpt.DataSource = DocPrint.PrintMovementDetail(no, sku); System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
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 = "XLS (*.XLS)|*.xls"; dialog.FilterIndex = 0; if (dialog.ShowDialog() != DialogResult.Cancel) { XtraReport report = GetReport(); string fileName = dialog.FileName; if (!fileName.EndsWith(".xls")) { fileName = fileName + ".xls"; } report.ExportToXls(fileName); } } }
private void exportFileXls(XtraReport report) { string reportPath = ""; SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "Save Here.xls"; if (sf.ShowDialog() == DialogResult.OK) { reportPath = Path.GetDirectoryName(sf.FileName) + sf.FileName; try { report.ExportToXls(sf.FileName); MessageBox.Show("Lưu thành công!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private MemoryStream PrintCPFContribution(string date1, string date2) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\Modules\Hr\Report\repx\CPF_Contribution.repx")); 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 = HrPrint.PrintCPFContribution(d1, d2); System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
private MemoryStream PrintExportVolumeByPort(string refType, string date1, string date2, string port, string userName) { XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\ReportFreightSea\ReportRepx\VolumeByPort.repx")); 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 = SeaFreightRptPrint.dsExportVolumeByPort(refType, d1, d2, port, userName); System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }
protected override ResultStatus Export() { string lsRptName = ConditionText().Trim(); StartExport(_ProgramID, lsRptName); try { //讀取資料 if (_Data == null || _Data.Rows.Count <= 0 || _defReport == null) { MessageDisplay.Info(MessageDisplay.MSG_NO_DATA); return(ResultStatus.Fail); } //開啟檔案 Workbook workbook = new Workbook(); //複製檔案 _D500Xx.Filename = PbFunc.wf_copy_file(_ProgramID, _ProgramID); if (_D500Xx.Filename == "") { return(ResultStatus.Fail); } _D500Xx.LogText = _D500Xx.Filename; if (lsRptName == "") { lsRptName = "報表條件:" + "(" + DateText() + ")"; } else { lsRptName = ConditionText().Trim() + " " + "(" + DateText() + ")"; } // Get its XLSX export options. XlsExportOptions xlsOptions = _defReport.ExportOptions.Xls; xlsOptions.SheetName = _ProgramID; //Export the report to XLSX. _defReport.ExportToXls(_D500Xx.Filename); /****************** * 開啟檔案 ******************/ workbook.LoadDocument(_D500Xx.Filename); /****************** * 切換Sheet ******************/ Worksheet worksheet = workbook.Worksheets[0]; for (int k = 0; k < 3; k++) { worksheet.Rows.Insert(0); } worksheet.Cells["F1"].Value = $"[{_ProgramID}]{_ProgramName}"; worksheet.Cells["F3"].Value = lsRptName; worksheet.Rows[3].AutoFitRows(); workbook.SaveDocument(_D500Xx.Filename); } catch (Exception ex) { WriteLog(ex); WfRunError(); } finally { EndExport(); } return(ResultStatus.Success); }
private MemoryStream PrintPL_Airhouse(string refN, string jobN, string userId) { string user = HttpContext.Current.User.Identity.Name; XtraReport rpt = new XtraReport(); rpt.LoadLayout(Server.MapPath(@"~\ReportAir\repx\Import\PL.repx")); DataSet set = AirFreightDocPrint.PrintPl_house(refN, jobN, userId); DataTable tab_mast = set.Tables[0]; DataTable tab_Inv = set.Tables[1]; DataTable tab_Dn = set.Tables[2]; DataTable tab_Ts = set.Tables[3]; DataTable tab_Cn = set.Tables[4]; DataTable tab_Pl = set.Tables[5]; DataTable tab_Vo = set.Tables[6]; DataTable tab_Cost = set.Tables[7]; if (tab_Inv.Rows.Count > 0) { DevExpress.XtraReports.UI.GroupFooterBand groupFooter_Inv = rpt.Report.Bands["GroupFooter_Inv"] as DevExpress.XtraReports.UI.GroupFooterBand; DevExpress.XtraReports.UI.XRSubreport subReport_Inv = new XRSubreport(); subReport_Inv.Name = "groupFooter_Inv"; groupFooter_Inv.Controls.Add(subReport_Inv); XtraReport rpt_Inv = new XtraReport(); rpt_Inv.LoadLayout(Server.MapPath(@"~\ReportAir\repx\import\Pl_1_Inv.repx")); subReport_Inv.ReportSource = rpt_Inv; rpt_Inv.DataSource = tab_Inv; } if (tab_Dn.Rows.Count > 0) { DevExpress.XtraReports.UI.GroupFooterBand groupFooter_Dn = rpt.Report.Bands["GroupFooter_Dn"] as DevExpress.XtraReports.UI.GroupFooterBand; DevExpress.XtraReports.UI.XRSubreport subReport_Dn = new XRSubreport(); subReport_Dn.Name = "groupFooter_Dn"; groupFooter_Dn.Controls.Add(subReport_Dn); XtraReport rpt_Dn = new XtraReport(); rpt_Dn.LoadLayout(Server.MapPath(@"~\ReportAir\repx\import\Pl_2_Dn.repx")); subReport_Dn.ReportSource = rpt_Dn; rpt_Dn.DataSource = tab_Dn; } if (tab_Ts.Rows.Count > 0) { DevExpress.XtraReports.UI.GroupFooterBand groupFooter_Ts = rpt.Report.Bands["GroupFooter_Ts"] as DevExpress.XtraReports.UI.GroupFooterBand; DevExpress.XtraReports.UI.XRSubreport subReport_Ts = new XRSubreport(); subReport_Ts.Name = "groupFooter_Ts"; groupFooter_Ts.Controls.Add(subReport_Ts); XtraReport rpt_Ts = new XtraReport(); rpt_Ts.LoadLayout(Server.MapPath(@"~\ReportAir\repx\import\Pl_3_Ts.repx")); subReport_Ts.ReportSource = rpt_Ts; rpt_Ts.DataSource = tab_Ts; } if (tab_Cn.Rows.Count > 0) { DevExpress.XtraReports.UI.GroupFooterBand groupFooter_Cn = rpt.Report.Bands["GroupFooter_Cn"] as DevExpress.XtraReports.UI.GroupFooterBand; DevExpress.XtraReports.UI.XRSubreport subReport_Cn = new XRSubreport(); subReport_Cn.Name = "groupFooter_Cn"; groupFooter_Cn.Controls.Add(subReport_Cn); XtraReport rpt_Cn = new XtraReport(); rpt_Cn.LoadLayout(Server.MapPath(@"~\ReportAir\repx\import\Pl_4_Cn.repx")); subReport_Cn.ReportSource = rpt_Cn; rpt_Cn.DataSource = tab_Cn; } if (tab_Pl.Rows.Count > 0) { DevExpress.XtraReports.UI.GroupFooterBand groupFooter_Pl = rpt.Report.Bands["GroupFooter_Pl"] as DevExpress.XtraReports.UI.GroupFooterBand; DevExpress.XtraReports.UI.XRSubreport subReport_Pl = new XRSubreport(); subReport_Pl.Name = "groupFooter_Pl"; groupFooter_Pl.Controls.Add(subReport_Pl); XtraReport rpt_Pl = new XtraReport(); rpt_Pl.LoadLayout(Server.MapPath(@"~\ReportAir\repx\import\Pl_5_Pl.repx")); subReport_Pl.ReportSource = rpt_Pl; rpt_Pl.DataSource = tab_Pl; } if (tab_Vo.Rows.Count > 0) { DevExpress.XtraReports.UI.GroupFooterBand groupFooter_Vo = rpt.Report.Bands["GroupFooter_Vo"] as DevExpress.XtraReports.UI.GroupFooterBand; DevExpress.XtraReports.UI.XRSubreport subReport_Vo = new XRSubreport(); subReport_Vo.Name = "groupFooter_Vo"; groupFooter_Vo.Controls.Add(subReport_Vo); XtraReport rpt_Vo = new XtraReport(); rpt_Vo.LoadLayout(Server.MapPath(@"~\ReportAir\repx\import\Pl_6_Vo.repx")); subReport_Vo.ReportSource = rpt_Vo; rpt_Vo.DataSource = tab_Vo; } if (tab_Cost.Rows.Count > 0) { DevExpress.XtraReports.UI.GroupFooterBand groupFooter_Cost = rpt.Report.Bands["GroupFooter_Costing"] as DevExpress.XtraReports.UI.GroupFooterBand; DevExpress.XtraReports.UI.XRSubreport subReport_Cost = new XRSubreport(); subReport_Cost.Name = "subReport_Cost"; groupFooter_Cost.Controls.Add(subReport_Cost); XtraReport rpt_Cost = new XtraReport(); rpt_Cost.LoadLayout(Server.MapPath(@"~\ReportAir\repx\import\Pl_7_Cost.repx")); subReport_Cost.ReportSource = rpt_Cost; rpt_Cost.DataSource = tab_Cost; } rpt.DataSource = tab_mast; System.IO.MemoryStream str = new MemoryStream(); if (docType == "1") { rpt.ExportToXls(str); } else { rpt.ExportToPdf(str); } return(str); }