本文整理汇总了C#中CrystalDecisions.CrystalReports.Engine.ReportDocument.Load方法的典型用法代码示例。如果您正苦于以下问题:C# ReportDocument.Load方法的具体用法?C# ReportDocument.Load怎么用?C# ReportDocument.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CrystalDecisions.CrystalReports.Engine.ReportDocument
的用法示例。
在下文中一共展示了ReportDocument.Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdLoad_Click
private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
{
ADODB.Recordset rs = default(ADODB.Recordset);
ADODB.Recordset rsData = default(ADODB.Recordset);
//Dim Report As New cryItemGroupCompare
//ReportNone.Load("cryNoRecords.rpt")
CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
Report.Load("cryItemGroupCompare.rpt");
ReportNone.Load("cryNoRecords");
modReport.cnnDBreport.Execute("DELETE LinkItem.* FROM LinkItem;");
rs = modReport.getRSreport(ref "SELECT * FROM Link Where LinkID=1 AND Link_SectionID=1");
modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT 1, DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales FROM DayEndStockItemLnk INNER JOIN aStockItem ON DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aStockItem.StockItemID WHERE " + rs.Fields("Link_SQL").Value + ";");
rs = modReport.getRSreport(ref "SELECT * FROM Link Where LinkID=2 AND Link_SectionID=1");
modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT 2, DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales FROM DayEndStockItemLnk INNER JOIN aStockItem ON DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aStockItem.StockItemID " + rs.Fields("Link_SQL").Value + " GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;");
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
rs = modReport.getRSreport(ref "SELECT Report.Report_Heading, aCompany.Company_Name FROM aCompany, Report;");
Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
Report.SetParameterValue("txtDayEnd", rs.Fields("Report_Heading"));
rs.Close();
rs = modReport.getRSreport(ref "SELECT Link.* From Link Where (((Link.Link_SectionID) = 1)) ORDER BY Link.Link_SectionID;");
if (rs.BOF | rs.EOF) {
ReportNone.SetParameterValue("txtCompanyName", Report.ParameterFields("txtCompanyName").ToString);
ReportNone.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString);
My.MyProject.Forms.frmReportShow.Text = ReportNone.ParameterFields("txtTitle").ToString;
My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = ReportNone;
My.MyProject.Forms.frmReportShow.mReport = ReportNone;
My.MyProject.Forms.frmReportShow.sMode = "0";
My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
My.MyProject.Forms.frmReportShow.ShowDialog();
return;
}
rsData = modReport.getRSreport(ref "SELECT LinkItem.*, Format([DayEnd_Date],'ddd dd mmm\", \"yyyy') AS dateName, DayEnd.DayEnd_Date FROM DayEnd INNER JOIN LinkItem ON DayEnd.DayEndID = LinkItem.LinkItem_DayEndID;");
if (rsData.BOF | rsData.EOF) {
ReportNone.SetParameterValue("txtCompanyName", Report.ParameterFields("txtCompanyName").ToString);
ReportNone.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString);
My.MyProject.Forms.frmReportShow.Text = ReportNone.ParameterFields("txtTitle").ToString;
My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = ReportNone;
My.MyProject.Forms.frmReportShow.mReport = ReportNone;
My.MyProject.Forms.frmReportShow.sMode = "0";
My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
My.MyProject.Forms.frmReportShow.ShowDialog();
return;
}
Report.Database.Tables(1).SetDataSource(rs);
Report.Database.Tables(2).SetDataSource(rsData);
//Report.VerifyOnEveryPrint = True
My.MyProject.Forms.frmReportShow.Text = Report.ParameterFields("txtTitle").ToString;
My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report;
My.MyProject.Forms.frmReportShow.mReport = Report;
My.MyProject.Forms.frmReportShow.sMode = "0";
My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
My.MyProject.Forms.frmReportShow.ShowDialog();
}
示例2: 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");
}
示例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: cmdLoad_Click
private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
{
string sql = null;
ADODB.Connection lConn = default(ADODB.Connection);
ADODB.Recordset rs = default(ADODB.Recordset);
ADODB.Recordset rsPurchase = default(ADODB.Recordset);
ADODB.Recordset rsSales = default(ADODB.Recordset);
ADODB.Recordset rsStock = default(ADODB.Recordset);
ADODB.Recordset rsCompany = default(ADODB.Recordset);
//Dim Report As New cryIncomeExpense
CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
Report.Load("cryIncomeExpense.rpt");
//UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
if (cmbMonthEnd.SelectedIndex) {
lConn = modRecordSet.openConnectionInstance(ref "month" + gMonth - cmbMonthEnd.SelectedIndex + ".mdb");
if (lConn == null)
return;
rsStock = new ADODB.Recordset();
rsStock.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
sql = "SELECT DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]+[DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS total, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]) AS opening, Sum([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]) AS sales, Sum([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]) AS shrink, Sum([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS grv From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;";
rsStock.Open(sql, lConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic);
rsSales = new ADODB.Recordset();
rsSales.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
//UPGRADE_WARNING: Couldn't resolve default property of object sql. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
sql = "SELECT [M_DayEnd].[DayEndID], [M_DayEnd].[DayEnd_Date], Sum([Declaration].[Declaration_Total]) AS SumOfSale_Total FROM Declaration INNER JOIN M_DayEnd ON [Declaration].[Declaration_DayEndID]=[M_DayEnd].[DayEndID] GROUP BY [M_DayEnd].[DayEndID], [M_DayEnd].[DayEnd_Date];";
rsSales.Open(sql, lConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic);
} else {
modApplication.modUpdate = 3;
modApplication.updateStockMovement();
sql = "SELECT DayEnd.DayEndID, DayEnd.DayEnd_Date, Sum(Declaration.Declaration_Total) AS SumOfSale_Total FROM Company, Declaration INNER JOIN DayEnd ON Declaration.Declaration_DayEndID = DayEnd.DayEndID Where (((DayEnd.DayEndID) <> [Company]![Company_DayEndID])) GROUP BY DayEnd.DayEndID, DayEnd.DayEnd_Date Union SELECT DayEnd.DayEndID, DayEnd.DayEnd_Date, Sum([SaleItem_Price]*[SaleItem_Quantity]) AS SumOfSale_Total FROM Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN ((Sale INNER JOIN (Company INNER JOIN DayEnd ON Company.Company_DayEndID = DayEnd.DayEndID) ON Sale.Sale_DayEndID = DayEnd.DayEndID) INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((SaleItem.SaleItem_Revoke) = 0)) GROUP BY Consignment.ConsignmentID, Consignment_1.ConsignmentID, DayEnd.DayEndID, DayEnd.DayEnd_Date ";
sql = sql + "HAVING (((Consignment.ConsignmentID) Is Null) AND ((Consignment_1.ConsignmentID) Is Null));";
rsSales = modRecordSet.getRS(ref sql);
rsStock = modRecordSet.getRS(ref "SELECT DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]+[DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS total, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]) AS opening, Sum([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]) AS sales, Sum([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]) AS shrink, Sum([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS grv From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;");
}
rsPurchase = modRecordSet.getRS(ref "SELECT DayEnd.DayEndID, DayEnd.DayEnd_Date, Sum(grvPosted.GRV_InvoiceInclusive) AS SumOfGRV_InvoiceInclusive, ([MonthEnd_BudgetSales]/[MonthEnd_Days]) AS saleBudget, ([MonthEnd_BudgetPurchases]/[MonthEnd_Days]) AS purchaseBudget FROM [SELECT GRV.* From GRV WHERE (((GRV.GRV_GRVStatusID)=3))]. AS grvPosted RIGHT JOIN (DayEnd INNER JOIN MonthEnd ON DayEnd.DayEnd_MonthEndID = MonthEnd.MonthEndID) ON grvPosted.GRV_DayEndID = DayEnd.DayEndID Where (((MonthEnd.MonthEndID) = " + gMonth - cmbMonthEnd.SelectedIndex + ")) GROUP BY DayEnd.DayEndID, DayEnd.DayEnd_Date, ([MonthEnd_BudgetSales]/[MonthEnd_Days]), ([MonthEnd_BudgetPurchases]/[MonthEnd_Days]);");
rsCompany = modRecordSet.getRS(ref "SELECT MonthEnd.* From MonthEnd WHERE (((MonthEnd.MonthEndID)=" + gMonth - cmbMonthEnd.SelectedIndex + "));");
rs = modRecordSet.getRS(ref "SELECT * FROM Company");
Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
rs.Close();
//ReportNone.Load("cryNoRecords.rpt")
CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
ReportNone.Load("cryNoRecords.rpt");
if (rsPurchase.BOF | rsPurchase.EOF) {
ReportNone.SetParameterValue("txtCompanyName", Report.ParameterFields("txtCompanyName").ToString);
ReportNone.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString);
My.MyProject.Forms.frmReportShow.Text = ReportNone.ParameterFields("txtTitle").ToString;
My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = ReportNone;
My.MyProject.Forms.frmReportShow.mReport = ReportNone;
My.MyProject.Forms.frmReportShow.sMode = "0";
My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
My.MyProject.Forms.frmReportShow.ShowDialog();
return;
}
//Report.Database.SetDataSource(rs)
Report.Database.Tables(1).SetDataSource(rsPurchase);
Report.Database.Tables(2).SetDataSource(rsSales);
Report.Database.Tables(3).SetDataSource(rsStock);
Report.Database.Tables(4).SetDataSource(rsCompany);
//UPGRADE_WARNING: Couldn't resolve default property of object Report.VerifyOnEveryPrint. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
//Report.VerifyOnEveryPrint = True
My.MyProject.Forms.frmReportShow.Text = Report.ParameterFields("txtTitle").ToString;
My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report;
My.MyProject.Forms.frmReportShow.mReport = Report;
My.MyProject.Forms.frmReportShow.sMode = "0";
My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
My.MyProject.Forms.frmReportShow.ShowDialog();
if (lConn == null) {
} else {
lConn.Close();
}
}
示例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: 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);
//判斷輸出檔案型態
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;
string s_par_DateRange = string.Empty;
string s_par_StoreChan = string.Empty;
String s_par_Route = string.Empty;
s_par_Program_ID = this.PageCode;
s_par_LoginUser = Session["UID"].ToString();
s_par_DateRange = slpStAcceptDate.StartDate.ToString().Trim() + " ~ " + slpStAcceptDate.EndDate.ToString().Trim();
s_par_StoreChan = SLP_StoreChain.Text + " " + ((TextBox)this.SLP_StoreChain.FindControl("TextBoxName")).Text;
s_par_Route = this.txtRouteStart.Text + " " + ((TextBox)this.txtRouteStart.FindControl("TextBoxName")).Text + " ~ " +
this.txtRouteEnd.Text + " " + ((TextBox)this.txtRouteEnd.FindControl("TextBoxName")).Text;
report.SetParameterValue("par_Program_ID", s_par_Program_ID);
report.SetParameterValue("par_LoginUser", s_par_LoginUser);
report.SetParameterValue("par_DateRange", s_par_DateRange);
report.SetParameterValue("par_StoreChan", s_par_StoreChan);
report.SetParameterValue("par_Route", s_par_Route);
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;
}
}
示例10: ShowReportA
private void ShowReportA(DataTable dtA, DataTable dtB, string V_FORM_TYPE)
{
#region 利用CrystalReport列印報表
//使用者名稱
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/VAM051/VAM052R01.rpt"));
DataSet ds = new DataSet();
dtA.TableName = "VAM052_R1";
ds.Tables.Add(dtA.Copy());
dtB.TableName = "VAM052_R2";
ds.Tables.Add(dtB.Copy());
report.SetDataSource(ds);
report.SetParameterValue("par_Count", Convert.ToString(dtA.Rows.Count + dtB.Rows.Count));
if (this.hidTYPE.Value == "1")
{
report.SetParameterValue("par_Program_ID", "註記解除");
report.SetParameterValue("par_YM", this.Label7.Text);
report.SetParameterValue("par_Source_date", "註記解除日期/時間:" + System.DateTime.Now.ToLongDateString());
report.SetParameterValue("par_LoginName", "註記解除人員:" + Session["UID"].ToString() + Login_Name);
}
else
{
report.SetParameterValue("par_Program_ID", "註記確認");
report.SetParameterValue("par_YM", this.SLP_YearMonth1.Text);
report.SetParameterValue("par_Source_date", "註記日期/時間:" + System.DateTime.Now.ToLongDateString());
report.SetParameterValue("par_LoginName", "註記人員:" + Session["UID"].ToString() + Login_Name);
}
//檔案匯出
if (V_FORM_TYPE == "XLS")
{
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=" + HttpUtility.UrlEncode("供應商單品結帳.XLS", System.Text.Encoding.UTF8));//匯出檔名
Response.ContentType = "application/xls";
Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
Response.Flush();
Response.Close();
}
else
{
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();
#endregion
}
示例11: 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
}
示例12: 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();
}
示例13: cmdPrint_Click
private void cmdPrint_Click(System.Object eventSender, System.EventArgs eventArgs)
{
ADODB.Recordset rs = default(ADODB.Recordset);
string sql = null;
//Dim Report As New cryKeyboardName
CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
Report.Load("cryKeyboardName.rpt");
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
rs = modRecordSet.getRS(ref "SELECT * FROM Company");
Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
rs.Close();
rs = modRecordSet.getRS(ref "SELECT KeyboardLayout.KeyboardLayout_Name, keyboard.keyboard_Name, KeyboardKeyboardLayoutLnk.KeyboardKeyboardLayoutLnk_Description, keyboard.keyboard_Order, keyboard.keyboard_Show FROM (KeyboardKeyboardLayoutLnk INNER JOIN keyboard ON KeyboardKeyboardLayoutLnk.KeyboardKeyboardLayoutLnk_KeyboardID = keyboard.KeyboardID) INNER JOIN KeyboardLayout ON KeyboardKeyboardLayoutLnk.KeyboardKeyboardLayoutLnk_KeyboardLayoutID = KeyboardLayout.KeyboardLayoutID Where (((KeyboardLayout.KeyboardLayoutID) = " + gParentID + ")) ORDER BY keyboard.keyboard_Order, keyboard.keyboard_Name;");
//ReportNone.Load("cryNoRecords.rpt")
CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
ReportNone.Load("cryNoRecords.rpt");
if (rs.BOF | rs.EOF) {
ReportNone.SetParameterValue("txtCompanyName", Report.ParameterFields("txtCompanyName").ToString);
ReportNone.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString);
My.MyProject.Forms.frmReportShow.Text = ReportNone.ParameterFields("txtTitle").ToString;
My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = ReportNone;
My.MyProject.Forms.frmReportShow.mReport = ReportNone;
My.MyProject.Forms.frmReportShow.sMode = "0";
My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
My.MyProject.Forms.frmReportShow.ShowDialog();
return;
}
Report.Database.Tables(0).SetDataSource(rs);
Report.Database.Tables(1).SetDataSource(rs);
//Report.VerifyOnEveryPrint = True
My.MyProject.Forms.frmReportShow.Text = Report.ParameterFields("txtTitle").ToString;
My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report;
My.MyProject.Forms.frmReportShow.mReport = Report;
My.MyProject.Forms.frmReportShow.sMode = "0";
My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
My.MyProject.Forms.frmReportShow.ShowDialog();
}
示例14: 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 { }
}
示例15: 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;
}
}