本文整理汇总了C#中CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource方法的典型用法代码示例。如果您正苦于以下问题:C# ReportDocument.SetDataSource方法的具体用法?C# ReportDocument.SetDataSource怎么用?C# ReportDocument.SetDataSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CrystalDecisions.CrystalReports.Engine.ReportDocument
的用法示例。
在下文中一共展示了ReportDocument.SetDataSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
crvReporte.Visible = true;
string fechainicial = Request.QueryString["fechainicial"].ToString();
string fechafinal = Request.QueryString["fechafinal"].ToString();
string idsede = Request.QueryString["idsede"].ToString();
string idproyecto = Request.QueryString["idproyecto"].ToString();
string idestado = Request.QueryString["idestado"].ToString();
ds = objPedidoDAO.ListarReportePedidos(AppUtilidad.stringToDateTime(fechainicial, "DD/MM/YYYY"),
AppUtilidad.stringToDateTime(fechafinal, "DD/MM/YYYY"),
Convert.ToInt32(idsede),
Convert.ToInt32(idproyecto),
idestado);
dt = ds.Tables[0];
CrystalDecisions.CrystalReports.Engine.ReportDocument rDoc;
rDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
rDoc.Load(Server.MapPath("rptReportePedidos.rpt")); // Your .rpt file path
rDoc.SetDataSource(dt); //set dataset to the report viewer.
rDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "Listado");
}
示例2: LoadCrystalReport
/// <summary>
/// 利用 CrystalReport 列印 Excel 報表
/// </summary>
/// <param name="s_FileName">Excel報表的檔名</param>
/// <param name="s_rptFilePath">rpt檔的路徑</param>
/// <param name="dt_Source">要列印的資料</param>
/// /// <param name="reportFormatType">檔案型態</param>
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(dt_Source);
string par_ProgramID = string.Empty;
string par_LoginUser = string.Empty;
#region 前置檢查與參數過濾
DropDownList ddlCodeFile1 = (DropDownList)(this.SLP_CodeFile1.FindControl("D1"));
string V_LOCATE_NO = this.SLP_CodeFile1.Text + " " + ddlCodeFile1.SelectedItem.Text;
string V_LOCATE_SECTOR_S = this.ddlS.Text;
string V_LOCATE_SECTOR_E = this.ddlE.Text;
par_ProgramID = this.PageCode;
par_LoginUser = Session["UID"].ToString() + " " + Get_LoginName();
#endregion
#region 組合查詢條件至ArrayList
ArrayList returnList = new ArrayList();
returnList.Clear();
report.SetParameterValue("V_LOCATE_NO", V_LOCATE_NO);
report.SetParameterValue("V_LOCATE_SECTOR_S", V_LOCATE_SECTOR_S);
report.SetParameterValue("V_LOCATE_SECTOR_E", V_LOCATE_SECTOR_E);
report.SetParameterValue("par_Program_ID", par_ProgramID);
report.SetParameterValue("par_LoginUser", par_LoginUser);
#endregion
//判斷輸出檔案型態
switch (reportFormatType)
{
case "EXCEL":
System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
byte[] bytesXLS = new byte[streamXLS.Length];
streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/vnd.ms-excel";
Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
Response.Flush();
Response.Close();
report.Close();
break;
case "PDF":
System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byte[] bytesPDF = new byte[streamPDF.Length];
streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
report.Close();
break;
default:
break;
}
}
示例3: ShowReportA
private void ShowReportA(DataTable dtA, DataTable dtB, string V_FORM_TYPE, string V_RPT)
{
#region 利用CrystalReport列印報表
//匯出檔案名稱
string FileName = "";
//使用者名稱
DataTable dt1 = new DataTable();
dt1 = (DataTable)Session["UserInfo"];
string Login_Name = dt1.Rows[0]["Name"].ToString();
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(Server.MapPath("./REPORT/VAM121/" + V_RPT + "01.rpt"));
DataSet ds = new DataSet();
dtA.TableName = "VAM122_R1";
ds.Tables.Add(dtA.Copy());
dtB.TableName = "VAM122_R2";
ds.Tables.Add(dtB.Copy());
report.SetDataSource(ds);
if (V_RPT == "VAM121R")
{
FileName = "進項憑證明細表(發票)";
report.SetParameterValue("par_Program_ID", V_RPT);
report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
if (this.SLP_SLPDateRange.StartDate.ToString() == "" && this.SLP_SLPDateRange.EndDate.ToString() == "")
report.SetParameterValue("par_Source_date", "全部");
else
report.SetParameterValue("par_Source_date", this.SLP_SLPDateRange.StartDate.ToString() + "-" + this.SLP_SLPDateRange.EndDate.ToString());
if (this.SLP_SLPDateRange1.StartDate.ToString() == "" && this.SLP_SLPDateRange1.EndDate.ToString() == "")
report.SetParameterValue("par_Keyin_date", "全部");
else
report.SetParameterValue("par_Keyin_date", this.SLP_SLPDateRange1.StartDate.ToString() + "-" + this.SLP_SLPDateRange1.EndDate.ToString());
if (this.SLP_VendorBase1.Text.Trim() == "" && this.SLP_VendorBase2.Text.Trim() == "")
{
report.SetParameterValue("par_Vandor", "全部");
}
else
{
report.SetParameterValue("par_Vandor", this.SLP_VendorBase1.Text.Trim() + "-" + this.SLP_VendorBase2.Text.Trim());
}
if (((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text == "ALL")
report.SetParameterValue("par_Tax_Type", "全部");
else
report.SetParameterValue("par_Tax_Type", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
}
else if (V_RPT == "VAM122R")
{
FileName = "進項憑證明細表(折讓)";
report.SetParameterValue("par_Program_ID_B", V_RPT);
report.SetParameterValue("par_LoginUser_B", Session["UID"].ToString() + Login_Name);
if (this.SLP_SLPDateRange.StartDate.ToString() == "" && this.SLP_SLPDateRange.EndDate.ToString() == "")
report.SetParameterValue("par_Source_date_B", "全部");
else
report.SetParameterValue("par_Source_date_B", this.SLP_SLPDateRange.StartDate.ToString() + "-" + this.SLP_SLPDateRange.EndDate.ToString());
if (this.SLP_SLPDateRange1.StartDate.ToString() == "" && this.SLP_SLPDateRange1.EndDate.ToString() == "")
report.SetParameterValue("par_Keyin_date_B", "全部");
else
report.SetParameterValue("par_Keyin_date_B", this.SLP_SLPDateRange1.StartDate.ToString() + "-" + this.SLP_SLPDateRange1.EndDate.ToString());
if (this.SLP_VendorBase1.Text.Trim() == "" && this.SLP_VendorBase2.Text.Trim() == "")
{
report.SetParameterValue("par_Vandor_B", "全部");
}
else
{
report.SetParameterValue("par_Vandor_B", this.SLP_VendorBase1.Text.Trim() + "-" + this.SLP_VendorBase2.Text.Trim());
}
if (((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text == "ALL")
report.SetParameterValue("par_Tax_Type_B", "全部");
else
report.SetParameterValue("par_Tax_Type_B", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
//report.SetParameterValue("par_Tax_Type_B", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
}
else if (V_RPT == "VAM123R")
{
FileName = "進項憑證明細表(發票與折讓)";
report.SetParameterValue("par_Program_ID", V_RPT);
report.SetParameterValue("par_Program_ID_B", V_RPT);
//.........这里部分代码省略.........
示例4: LoadCrystalReport
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(dt_Source);
//判斷輸出檔案型態
switch (reportFormatType)
{
case "EXCEL":
System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
byte[] bytesXLS = new byte[streamXLS.Length];
streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
Response.Flush();
Response.Close();
break;
case "PDF":
//string s_par_Program_ID = this.PageCode;
string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();
string s_par_Program_ID = "MKT11";
string s_par_LoginUser = Session["UID"].ToString() + " " + Login_Name;
string s_par_Vendor = SLP_Vendor.Text + " " + SLP_Vendor.Name;
string s_par_RootNo = SLP_RootNo_S.Text + " " + SLP_RootNo_S.Name +" ~ " + SLP_RootNo_E.Text + " " + SLP_RootNo_E.Name;
string s_par_PMA = SLP_PMA_S.Text + " " + SLP_PMA_S.Name + " ~ " + SLP_PMA_E.Text + " " + SLP_PMA_E.Name;
string s_par_Category = SLP_Category_S.Text + " " + SLP_Category_S.Name + " ~ " + SLP_Category_E.Text + " " + SLP_Category_E.Name;
string s_par_SortOut = SLP_SortOut_S.Text + " " + SLP_SortOut_S.Name + " ~ " + SLP_SortOut_E.Text + " " + SLP_SortOut_E.Name;
string s_par_Item = SLP_SKU.Text + " " + SLP_SKU.Name;
string s_par_Period = SLP_ItemPeriod.Text;
string s_par_PeriodCount = SLP_SLPNumber.Text;
string s_par_Order ="";
if ( ddl_Order.SelectedValue=="1"){
s_par_Order = "期別降冪";
}
else if ( ddl_Order.SelectedValue=="2"){
s_par_Order = "期別升冪";
}
report.SetParameterValue("par_Program_ID", s_par_Program_ID);
report.SetParameterValue("par_LoginUser", s_par_LoginUser);
report.SetParameterValue("par_Vendor", s_par_Vendor);
report.SetParameterValue("par_RootNo", s_par_RootNo);
report.SetParameterValue("par_PMA", s_par_PMA);
report.SetParameterValue("par_Category", s_par_Category);
report.SetParameterValue("par_SortOut", s_par_SortOut);
report.SetParameterValue("par_Item", s_par_Item);
report.SetParameterValue("par_Period", s_par_Period);
report.SetParameterValue("par_PeriodCount", s_par_PeriodCount);
report.SetParameterValue("par_Order", s_par_Order);
System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byte[] bytesPDF = new byte[streamPDF.Length];
streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
break;
default:
break;
}
}
示例5: LoadCrystalReport
/// <summary>
/// 利用 CrystalReport 列印 Excel 報表
/// </summary>
/// <param name="s_FileName">Excel報表的檔名</param>
/// <param name="s_rptFilePath">rpt檔的路徑</param>
/// <param name="dt_Source">要列印的資料</param>
/// /// <param name="reportFormatType">檔案型態</param>
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(dt_Source);
string par_ProgramID = string.Empty;
string par_LoginUser = string.Empty;
#region 前置檢查與參數過濾
string par_S_Vendor = this.SLP_VendorBaseS.Text + " " + this.SLP_VendorBaseS.Name;
string par_E_Vendor = this.SLP_VendorBaseE.Text + " " + this.SLP_VendorBaseE.Name;
string par_S_PMA = this.SLP_PMAS.Text + " " + this.SLP_PMAS.Name;
string par_E_PMA = this.SLP_PMAE.Text + " " + this.SLP_PMAE.Name;
string par_S_RootNo = this.SLP_RootNoS.Text + " " + this.SLP_RootNoS.Name;
string par_E_RootNo = this.SLP_RootNoE.Text + " " + this.SLP_RootNoE.Name;
string par_S_LocateNo = this.SLP_SimpleLocateSec1.Text1 + " " + this.SLP_SimpleLocateSec1.Name;
string par_E_LocateNo = this.SLP_SimpleLocateSec2.Text1 + " " + this.SLP_SimpleLocateSec2.Name;
string par_S_LocateSec = SLP_SimpleLocateSec1.Text2.Trim() != "" ? this.SLP_SimpleLocateSec1.Text1 + SLP_SimpleLocateSec1.Text2 : "";
string par_E_LocateSec = SLP_SimpleLocateSec2.Text2.Trim() != "" ? this.SLP_SimpleLocateSec2.Text1 + SLP_SimpleLocateSec2.Text2 : "";
string par_Item = this.SLP_SKU.Text + " " + this.SLP_SKU.Name;
string par_Period = this.SLP_ItemPeriod.Text + " " + this.SLP_ItemPeriod.Name;
par_ProgramID = this.PageCode;
par_LoginUser = Session["UID"].ToString();
#endregion
#region 組合查詢條件至ArrayList
ArrayList returnList = new ArrayList();
returnList.Clear();
report.SetParameterValue("par_S_Vendor", par_S_Vendor);
report.SetParameterValue("par_E_Vendor", par_E_Vendor);
report.SetParameterValue("par_S_PMA", par_S_PMA);
report.SetParameterValue("par_E_PMA", par_E_PMA);
report.SetParameterValue("par_S_RootNo", par_S_RootNo);
report.SetParameterValue("par_E_RootNo", par_E_RootNo);
report.SetParameterValue("par_S_LocateNo", par_S_LocateNo);
report.SetParameterValue("par_E_LocateNo", par_E_LocateNo);
report.SetParameterValue("par_S_LocateSec", par_S_LocateSec);
report.SetParameterValue("par_E_LocateSec", par_E_LocateSec);
report.SetParameterValue("par_Item", par_Item);
report.SetParameterValue("par_Period", par_Period);
report.SetParameterValue("par_ProgramID", par_ProgramID);
report.SetParameterValue("par_LoginUser", par_LoginUser);
#endregion
//判斷輸出檔案型態
switch (reportFormatType)
{
case "EXCEL":
System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
byte[] bytesXLS = new byte[streamXLS.Length];
streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/vnd.ms-excel";
Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
Response.Flush();
Response.Close();
break;
case "PDF":
System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byte[] bytesPDF = new byte[streamPDF.Length];
streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
//.........这里部分代码省略.........
示例6: LoadCrystalReport
/// <summary>
/// 利用 CrystalReport 列印 Excel 報表
/// </summary>
/// <param name="s_FileName">Excel報表的檔名</param>
/// <param name="s_rptFilePath">rpt檔的路徑</param>
/// <param name="dt_Source">要列印的資料</param>
/// /// <param name="reportFormatType">檔案型態</param>
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(dt_Source);
string par_ProgramID = string.Empty;
string par_LoginUser = string.Empty;
#region 前置檢查與參數過濾
string par_S_PDate = this.SLP_SLPDateRange.StartDate;
string par_E_PDate = this.SLP_SLPDateRange.EndDate;
string par_BatchNo = this.txtBatchNo.Text;
string par_ChanNo = this.SLP_StoreChain.Text + " " + this.SLP_StoreChain.Name;
string par_ChanSourceNo = this.txtChanSourceNo.Text;
string par_S_SignDate = this.SLP_SignDate.StartDate;
string par_E_SignDate = this.SLP_SignDate.EndDate;
string par_Item = this.SLP_SKU.Text + " " + this.SLP_SKU.Name;
string par_Period = this.SLP_ItemPeriod.Text + " " + this.SLP_ItemPeriod.Name;
string par_ItemMap = this.txtItemMap.Text;
par_ProgramID = this.PageCode;
par_LoginUser = Session["UID"].ToString();
#endregion
#region 組合查詢條件至ArrayList
ArrayList returnList = new ArrayList();
returnList.Clear();
report.SetParameterValue("par_S_PDate", par_S_PDate);
report.SetParameterValue("par_E_PDate", par_E_PDate);
report.SetParameterValue("par_BatchNo", par_BatchNo);
report.SetParameterValue("par_ChanNo", par_ChanNo);
report.SetParameterValue("par_ChanSourceNo", par_ChanSourceNo);
report.SetParameterValue("par_S_SignDate", par_S_SignDate);
report.SetParameterValue("par_E_SignDate", par_E_SignDate);
report.SetParameterValue("par_Item", par_Item);
report.SetParameterValue("par_Period", par_Period);
report.SetParameterValue("par_ItemMap", par_ItemMap);
report.SetParameterValue("par_ProgramID", par_ProgramID);
report.SetParameterValue("par_LoginUser", par_LoginUser);
#endregion
//判斷輸出檔案型態
switch (reportFormatType)
{
case "EXCEL":
System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
byte[] bytesXLS = new byte[streamXLS.Length];
streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/vnd.ms-excel";
Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
Response.Flush();
Response.Close();
break;
case "PDF":
System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byte[] bytesPDF = new byte[streamPDF.Length];
streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
break;
default:
break;
}
}
示例7: LoadCrystalReport
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(dt_Source);
//判斷輸出檔案型態
switch (reportFormatType)
{
case "EXCEL":
System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
byte[] bytesXLS = new byte[streamXLS.Length];
streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/vnd.ms-excel";
Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
Response.Flush();
Response.Close();
break;
case "PDF":
string s_par_Program_ID = string.Empty;
string s_par_LoginUser = string.Empty;
s_par_Program_ID = this.PageCode;
s_par_LoginUser = Session["UID"].ToString();
System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byte[] bytesPDF = new byte[streamPDF.Length];
streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
break;
default:
break;
}
}
示例8: ExportReport
//Crystal Report 直接輸出 PDF 檔
private void ExportReport(DataTable dt)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(Server.MapPath("./REPORT/CGR021R01.rpt"));
report.SetDataSource(dt);
//CrystalReport Parameter 參數設定
string Program_ID = string.Empty;
string LoginUser = string.Empty;
Program_ID = this.PageCode.Substring(0, 5) + "R01";
LoginUser = Session["UID"].ToString();
report.SetParameterValue("par_Program_ID", this.PageCode);
report.SetParameterValue("par_LoginUser", LoginUser);
//檔案匯出
System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byte[] bytesPDF = new byte[streamPDF.Length];
streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
//Export File
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("退貨結轉檢核異常報表.PDF", System.Text.Encoding.UTF8));//匯出檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
report.Close();
}
示例9: Show_Report2
/// <summary>
/// 匯出PDF
/// </summary>
/// <param name="dt">列印資料</param>
/// <param name="s_Status">狀態,"Detail"明細表,"Gather"彙總表</param>
private void Show_Report2(DataTable dt, string s_Status)
{
#region
//string s_FileName = txt_Out_FileName.Text;
string s_FileName = "客服線上紀錄表(明細).pdf";
string s_RptName = "./REPORT/CRM131/CRM131_Report_Detl.rpt";
if (s_Status == "Detail")
{
s_FileName = "客服線上紀錄表(明細).pdf";
s_RptName = "./REPORT/CRM131/CRM131_Report_Detl.rpt";
}
else if (s_Status == "Gather")
{
s_FileName = "客服線上紀錄表(彙總).pdf";
s_RptName = "./REPORT/CRM131/CRM131_Report_Main.rpt";
}
s_FileName = HttpUtility.UrlEncode(s_FileName, System.Text.Encoding.UTF8);
report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
#region Load 報表
report.Load(Server.MapPath(s_RptName));
report.SetDataSource(dt);
// Set Parameter
report.SetParameterValue("par_Program_ID", this.PageCode);
report.SetParameterValue("par_LoginUser", Session["UID"].ToString());
report.SetParameterValue("par_DateRange", this.slp_DateRange.StartDate + "~" + this.slp_DateRange.EndDate);
report.SetParameterValue("par_StoreChain", this.slp_StoreChain_B.Text + "~" + this.slp_StoreChain_E.Text);
report.SetParameterValue("par_Z_O", this.slp_Z_O_B.Text + "~" + this.slp_Z_O_E.Text);
#endregion
#region 轉出PDF
System.IO.Stream stream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
stream.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.Flush();
Response.Close();
report.Close();
#endregion
#endregion
}
示例10: LoadCrystalReport
/// <summary>
/// 利用 CrystalReport 列印 Excel 報表
/// </summary>
/// <param name="s_FileName">Excel報表的檔名</param>
/// <param name="s_rptFilePath">rpt檔的路徑</param>
/// <param name="dt_Source">要列印的資料</param>
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source)
{
if (s_FileName.ToLower().IndexOf(".xls") < 0)
{
s_FileName = s_FileName + ".xls";
}
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(dt_Source);
System.IO.Stream stream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
stream.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.Flush();
Response.Close();
report.Close();
}
示例11: ShowReport
private void ShowReport(DataTable Dt)
{
try
{
string s_par_Program_ID = string.Empty;
string s_par_LoginUser = string.Empty;
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(Server.MapPath("./REPORT/INV021R0" + rblREPORT.SelectedValue + ".rpt"));
report.SetDataSource(Dt);
DataTable userName = (DataTable)Session["UserInfo"];
string UName = userName.Rows[0]["Name"].ToString();
report.SetParameterValue("par_Program_ID", this.PageCode);
report.SetParameterValue("par_LoginUser", Session["UID"].ToString());
report.SetParameterValue("par_LoginUser_Name", UName);
System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byte[] bytesPDF = new byte[streamPDF.Length];
streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
//Export File
Response.ClearContent();
Response.ClearHeaders();
string rpt_name = "";
if (rblREPORT.SelectedValue == "1")
rpt_name = "儲區庫存匯總表_" + DateTime.Now.ToString("yyyyMMdd") + ".PDF";
else
rpt_name = "儲位庫存明細表_" + DateTime.Now.ToString("yyyyMMdd") + ".PDF";
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(rpt_name, System.Text.Encoding.UTF8));//匯出檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
}
catch (Exception ex)
{
ErrorMsgLabel.Text = ex.Message;
}
finally { }
}
示例12: LoadCrystalReport
/// <summary>
/// 利用 CrystalReport 列印 Excel 報表
/// </summary>
/// <param name="s_FileName">Excel報表的檔名</param>
/// <param name="s_rptFilePath">rpt檔的路徑</param>
/// <param name="dt_Source">要列印的資料</param>
/// /// <param name="reportFormatType">檔案型態</param>
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(dt_Source);
string s_par_Program_ID = string.Empty;
string s_par_LoginUser = string.Empty;
string s_par_LoginName = string.Empty;
string s_par_1 = string.Empty;
string s_par_2 = string.Empty;
string s_par_3 = string.Empty;
s_par_Program_ID = this.PageCode;
s_par_LoginUser = Session["UID"].ToString();
s_par_LoginName = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();
s_par_1 = SLP_PICK_DATE.StartDate + " ~ " + SLP_PICK_DATE.EndDate;
s_par_2 = ddlLineStart.Text + " ~ " + ddlLineEnd.Text;
s_par_3 = txtSTATION_NO_S.Text + " ~ " + txtSTATION_NO_E.Text;
report.SetParameterValue("par_Program_ID", s_par_Program_ID);
report.SetParameterValue("par_LoginUser", s_par_LoginUser);
report.SetParameterValue("par_LoginName", s_par_LoginName);
report.SetParameterValue("par_1", s_par_1);
report.SetParameterValue("par_2", s_par_2);
report.SetParameterValue("par_3", s_par_3);
report.SetParameterValue("par_Type", reportFormatType);
//判斷輸出檔案型態
switch (reportFormatType)
{
case "EXCEL":
System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
byte[] bytesXLS = new byte[streamXLS.Length];
streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/vnd.ms-excel";
Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
Response.Flush();
Response.Close();
break;
case "PDF":
System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byte[] bytesPDF = new byte[streamPDF.Length];
streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
break;
default:
break;
}
}
示例13: ShowReport
/// <summary>
/// show報表
/// </summary>
private void ShowReport(DataTable Dt)
{
try
{
string strFileName = "";
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
if (TabContainer2.ActiveTabIndex == 0)
{
report.Load(Server.MapPath("./REPORT/MKT07/CRMKT07R01.rpt"));
strFileName = HttpUtility.UrlEncode("PMA(大分類)銷售查詢.PDF", System.Text.Encoding.UTF8);
}
if (TabContainer2.ActiveTabIndex == 1)
{
report.Load(Server.MapPath("./REPORT/MKT07/CRMKT07R02.rpt"));
strFileName = HttpUtility.UrlEncode("PMA(中分類)銷售查詢.PDF", System.Text.Encoding.UTF8);
}
if (TabContainer2.ActiveTabIndex == 2)
{
report.Load(Server.MapPath("./REPORT/MKT07/CRMKT07R03.rpt"));
strFileName = HttpUtility.UrlEncode("PMA(小分類)銷售查詢.PDF", System.Text.Encoding.UTF8);
}
report.SetDataSource(Dt);
string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();
report.SetParameterValue("par_Program_ID", "MKT07");
report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
report.SetParameterValue("par_StAcceptDate", SLP_MDC_START_DATE.StartDate + "~" + SLP_MDC_START_DATE.EndDate);
if (TabContainer2.ActiveTabIndex == 0)
{
report.SetParameterValue("par_ROOTDate", SLP_ROOT_NO_S.Text + Page.Request.Form[SLP_ROOT_NO_S.TextBox_Name.UniqueID] + "~" + SLP_ROOT_NO_E.Text + Page.Request.Form[SLP_ROOT_NO_E.TextBox_Name.UniqueID]);
report.SetParameterValue("par_PMADate", SLP_PMA_S.Text + Page.Request.Form[SLP_PMA_S.TextBox_Name.UniqueID] + "~" + SLP_PMA_E.Text + Page.Request.Form[SLP_PMA_E.TextBox_Name.UniqueID]);
}
if (TabContainer2.ActiveTabIndex == 1)
{
report.SetParameterValue("par_ROOTDate", SLP_ROOT_NO_S.Text + Page.Request.Form[SLP_ROOT_NO_S.TextBox_Name.UniqueID] + "~" + SLP_ROOT_NO_E.Text + Page.Request.Form[SLP_ROOT_NO_E.TextBox_Name.UniqueID]);
report.SetParameterValue("par_PMADate", SLP_PMA_S.Text + Page.Request.Form[SLP_PMA_S.TextBox_Name.UniqueID] + "~" + SLP_PMA_E.Text + Page.Request.Form[SLP_PMA_E.TextBox_Name.UniqueID]);
report.SetParameterValue("par_CATEGORYDate", SLP_CATEGORY_S.Text + Page.Request.Form[SLP_CATEGORY_S.TextBox_Name.UniqueID] + "~" + SLP_CATEGORY_E.Text + Page.Request.Form[SLP_CATEGORY_E.TextBox_Name.UniqueID]);
}
if (TabContainer2.ActiveTabIndex == 2)
{
report.SetParameterValue("par_ROOTDate", SLP_ROOT_NO_S.Text + Page.Request.Form[SLP_ROOT_NO_S.TextBox_Name.UniqueID] + "~" + this.SLP_ROOT_NO_E.Text + Page.Request.Form[SLP_ROOT_NO_E.TextBox_Name.UniqueID]);
report.SetParameterValue("par_PMADate", SLP_PMA_S.Text + Page.Request.Form[SLP_PMA_S.TextBox_Name.UniqueID] + "~" + SLP_PMA_E.Text + Page.Request.Form[SLP_PMA_E.TextBox_Name.UniqueID]);
report.SetParameterValue("par_CATEGORYDate", SLP_CATEGORY_S.Text + Page.Request.Form[SLP_CATEGORY_S.TextBox_Name.UniqueID] + "~" + SLP_CATEGORY_E.Text + Page.Request.Form[SLP_CATEGORY_E.TextBox_Name.UniqueID]);
report.SetParameterValue("par_SORTOUTDate", SLP_SORTOUT_S.Text + Page.Request.Form[SLP_SORTOUT_S.TextBox_Name.UniqueID] + "~" + SLP_SORTOUT_E.Text + Page.Request.Form[SLP_SORTOUT_E.TextBox_Name.UniqueID]);
}
System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byte[] bytesPDF = new byte[streamPDF.Length];
streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
//export file
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);//pdf檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
}
catch (Exception ex)
{
ErrorMsgLabel.Text = ex.Message;
}
finally { }
}
示例14: LoadCrystalReport
/// <summary>
/// 利用 CrystalReport 列印報表
/// </summary>
/// <param name="s_FileName">Excel報表的檔名</param>
/// <param name="s_rptFilePath">rpt檔的路徑</param>
/// <param name="dt_Source">要列印的資料</param>
/// <param name="reportFormatType">檔案型態</param>
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(dt_Source);
#region 取得各輸入值
string s_par_Program_ID = string.Empty;
string s_par_LoginUser = string.Empty;
string s_par_ST_Accept_Date = string.Empty;
string s_par_Trans_No_S = string.Empty;
string s_par_Trans_No_E = string.Empty;
string s_par_Trans_Vendor_S = string.Empty;
string s_par_Trans_Vendor_E = string.Empty;
string s_par_Route_S = string.Empty;
string s_par_Route_E = string.Empty;
string s_par_StoreChain_S = string.Empty;
string s_par_StoreChain_E = string.Empty;
string s_par_Report = string.Empty;
s_par_Program_ID = this.PageCode;
s_par_LoginUser = Session["UID"].ToString();
s_par_ST_Accept_Date = SLP_SLPDate.Text;
s_par_Trans_No_S = SLP_Trans_No_S.Text + " " + ((DropDownList)SLP_Trans_No_S.FindControl("D1")).SelectedItem.Text;
s_par_Trans_No_E = SLP_Trans_No_E.Text + " " + ((DropDownList)SLP_Trans_No_E.FindControl("D1")).SelectedItem.Text;
s_par_Trans_Vendor_S = SLP_Trans_Vendor_S.Text + " " + ((DropDownList)SLP_Trans_Vendor_S.FindControl("D1")).SelectedItem.Text;
s_par_Trans_Vendor_E = SLP_Trans_Vendor_E.Text + " " + ((DropDownList)SLP_Trans_Vendor_E.FindControl("D1")).SelectedItem.Text;
if (((TextBox)SLP_Route_S.FindControl("TextBoxCode")).Text != "")
{
s_par_Route_S = ((TextBox)SLP_Route_S.FindControl("TextBoxCode")).Text + " " + Request[SLP_Route_S.TextBox_Name.UniqueID].ToString();
}
else
{
s_par_Route_S = "";
}
if (((TextBox)SLP_Route_E.FindControl("TextBoxCode")).Text != "")
{
s_par_Route_E = ((TextBox)SLP_Route_E.FindControl("TextBoxCode")).Text + " " + Request[SLP_Route_E.TextBox_Name.UniqueID].ToString();
}
else
{
s_par_Route_E = "";
}
if (((TextBox)SLP_StoreChain_S.FindControl("TextBoxCode")).Text != "")
{
s_par_StoreChain_S = ((TextBox)SLP_StoreChain_S.FindControl("TextBoxCode")).Text + " " + Request[SLP_StoreChain_S.TextBox_Name.UniqueID].ToString();
}
else
{
s_par_StoreChain_S = "";
}
if (((TextBox)SLP_StoreChain_E.FindControl("TextBoxCode")).Text != "")
{
s_par_StoreChain_E = ((TextBox)SLP_StoreChain_E.FindControl("TextBoxCode")).Text + " " + Request[SLP_StoreChain_E.TextBox_Name.UniqueID].ToString();
}
else
{
s_par_StoreChain_E = "";
}
s_par_Report = rblPrintType.SelectedItem.Text;
#endregion
report.SetParameterValue("par_Program_ID", s_par_Program_ID);
report.SetParameterValue("par_LoginUser", s_par_LoginUser);
report.SetParameterValue("par_ST_Accept_Date", s_par_ST_Accept_Date);
report.SetParameterValue("par_Trans_No", s_par_Trans_No_S + " ~ " + s_par_Trans_No_E);
report.SetParameterValue("par_Trans_Vendor", s_par_Trans_Vendor_S + " ~ " + s_par_Trans_Vendor_E);
report.SetParameterValue("par_Routee", s_par_Route_S + " ~ " + s_par_Route_E);
report.SetParameterValue("par_StoreChain", s_par_StoreChain_S + " ~ " + s_par_StoreChain_E);
report.SetParameterValue("par_Report", s_par_Report);
#region 判斷輸出檔案型態並輸出
switch (reportFormatType)
{
case "EXCEL":
System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
byte[] bytesXLS = new byte[streamXLS.Length];
streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
//.........这里部分代码省略.........
示例15: LoadCrystalReport
/// <summary>
/// show報表
/// </summary>
//private void ShowReport(DataTable Dt)
//{
// try
// {
// string s_par_Program_ID = string.Empty;
// string s_par_LoginUser = string.Empty;
// CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
// report.Load(Server.MapPath("./REPORT/CGD251R01.rpt"));
// report.SetDataSource(Dt);
// s_par_Program_ID = this.PageCode;
// s_par_LoginUser = Session["UID"].ToString();
// //ParameterFields pars = new ParameterFields();
// //AddParameter("par_Program_ID", s_par_Program_ID, pars);
// //AddParameter("par_LoginUser", s_par_LoginUser, pars);
// this.CrystalReportViewer1.ReportSource = report;
// //this.CrystalReportViewer1.ParameterFieldInfo.Add(pars[0]);
// //this.CrystalReportViewer1.ParameterFieldInfo.Add(pars[1]);
// this.CrystalReportViewer1.Visible = true;
// Session["Rpt_Data_1" + PageTimeStamp.Value] = Dt;
// Session["ButtonSelect"] = "ShowReport";
// }
// catch (Exception ex)
// {
// ErrorMsgLabel.Text = ex.Message;
// }
// finally { }
//}
/// <summary>
/// Show未列印報表
/// </summary>
/// <param name="Dt"></param>
//private void ShowUnprintReport(DataTable Dt)
//{
// try
// {
// string s_par_Program_ID = string.Empty;
// string s_par_LoginUser = string.Empty;
// CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
// report.Load(Server.MapPath("./REPORT/CGD251R02.rpt"));
// report.SetDataSource(Dt);
// s_par_Program_ID = this.PageCode;
// s_par_LoginUser = Session["UID"].ToString();
// ParameterFields pars = new ParameterFields();
// AddParameter("par_Program_ID", s_par_Program_ID, pars);
// AddParameter("par_LoginUser", s_par_LoginUser, pars);
// this.CrystalReportViewer1.ReportSource = report;
// this.CrystalReportViewer1.ParameterFieldInfo.Add(pars[0]);
// this.CrystalReportViewer1.ParameterFieldInfo.Add(pars[1]);
// this.CrystalReportViewer1.Visible = true;
// Session["Rpt_Data_2" + PageTimeStamp.Value] = Dt;
// Session["ButtonSelect"] = "ShowUnprintReport";
// }
// catch (Exception ex)
// {
// ErrorMsgLabel.Text = ex.Message;
// }
// finally { }
//}
/// <summary>
/// 利用 CrystalReport 列印 Excel 報表
/// </summary>
/// <param name="s_FileName">Excel報表的檔名</param>
/// <param name="s_rptFilePath">rpt檔的路徑</param>
/// <param name="dt_Source">要列印的資料</param>
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable Dt)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(Dt);
string s_par_Program_ID = this.PageCode;
string s_par_LoginUser = Session["UID"].ToString();
this.CrystalReportViewer1.ReportSource = report;
//.........这里部分代码省略.........