本文整理汇总了C#中ReportDocument.ExportToHttpResponse方法的典型用法代码示例。如果您正苦于以下问题:C# ReportDocument.ExportToHttpResponse方法的具体用法?C# ReportDocument.ExportToHttpResponse怎么用?C# ReportDocument.ExportToHttpResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReportDocument
的用法示例。
在下文中一共展示了ReportDocument.ExportToHttpResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowGenericRpt
public void ShowGenericRpt()
{
try
{
bool isValid = true;
string strReportName = System.Web.HttpContext.Current.Session["ReportName"].ToString(); // Setting ReportName
if (string.IsNullOrEmpty(strReportName))
{
isValid = false;
}
if (isValid)
{
ReportDocument rd = new ReportDocument();
string strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Report//" + strReportName;
rd.Load(strRptPath);
rd.VerifyDatabase();
rd.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "crReport");
// Clear all sessions value
Session["ReportName"] = null;
}
else
{
Response.Write("<H2>Nothing Found; No Report name found</H2>");
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
示例2: cmdExportarExcel_Click
protected void cmdExportarExcel_Click(object sender, EventArgs e)
{
String regionCodigo = txtRegionCodigo.Text;
String zonaCodigo = txtZonaCodigo.Text;
try
{
String db_databaseName = connectionBL.getDataBaseName();
String db_serverName = connectionBL.getServerName();
String db_userID = connectionBL.getUserID();
String db_password = connectionBL.getPassword();
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("../CrystalReports/crReporteSeguimiento.rpt"));
rpt.SetDatabaseLogon("", "", ".", db_databaseName);
rpt.SetParameterValue("@regionCodigo", regionCodigo);
rpt.SetParameterValue("@zonaCodigo", zonaCodigo);
rpt.SetParameterValue("@estadoVerificiado", Convert.DBNull);
rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Reporte_seguimientos_" + DateFormatter.getTimestamp(DateTime.Now));
/*
rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Prueba_ExcelNormal");
//rpt.ExportToHttpResponse(ExportFormatType.ExcelRecord, Response, true, "Prueba_ExcelRecord");
*/
}
catch (Exception ex)
{
//System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
示例3: ExportExcel
//Exporta a Excel el grid
protected void ExportExcel(object sender, EventArgs e)
{
string sucursal = cmbSucursal.Value.ToString();
//1. Configurar la conexión y el tipo de comando
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString);
try
{
SqlCommand comando = new SqlCommand("web_spS_ObtenerRItemsAdicionales", conn);
SqlDataAdapter adaptador = new SqlDataAdapter(comando);
DataTable dt = new DataTable();
adaptador.SelectCommand.CommandType = CommandType.StoredProcedure;
adaptador.SelectCommand.Parameters.Add(@"Sucursal", SqlDbType.Char).Value = sucursal;
adaptador.Fill(dt);
ReportDocument reporteResumenExcel = new ReportDocument();
reporteResumenExcel.Load(Server.MapPath("reportess/ResumenOCPrecios.rpt"));
reporteResumenExcel.SetDataSource(dt);
reporteResumenExcel.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, true, "Resumen de OC: " + sucursal);
reporteResumenExcel.Close();
reporteResumenExcel.Dispose();
}
catch (Exception ex)
{
ex.Message.ToString();
}
finally
{
if (conn.State != ConnectionState.Closed)
conn.Close();
conn.Dispose();
}
}
示例4: cmdExportarExcel_Click
protected void cmdExportarExcel_Click(object sender, EventArgs e)
{
String regionCodigo = lblRegionCodigo.Text;
String zonaCodigo = lblZonaCodigo.Text;
String fechaInscripcion = txtFechaInscripcion.Text;
String campanhaInscripcion = txtCampaniaInscripcion.Text;
String documentoNumero = txtDocumentoIdentidad.Text;
String consultoraCodigo = txtCodigoConsultora.Text;
String apellidoPaterno = txtApellidoPaterno.Text;
String apellidoMaterno = txtApellidoMaterno.Text;
String nombres = txtNombres.Text;
int intEstadoVerificado = Convert.ToInt32(ddlEstadoVerificado.SelectedValue);
int intModoGrabacion = Convert.ToInt32(ddlModoGrabacion.SelectedValue);
try
{
String db_databaseName = connectionBL.getDataBaseName();
String db_serverName = connectionBL.getServerName();
String db_userID = connectionBL.getUserID();
String db_password = connectionBL.getPassword();
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("../CrystalReports/crReporteIncorporacionDetalle.rpt"));
rpt.SetDatabaseLogon("", "", ".", db_databaseName);
rpt.SetParameterValue("@regionCodigo", regionCodigo);
rpt.SetParameterValue("@zonaCodigo", zonaCodigo);
rpt.SetParameterValue("@fechaInscripcion", Convert.DBNull); // < por ahora null
rpt.SetParameterValue("@campanhaInscripcion", campanhaInscripcion);
rpt.SetParameterValue("@numeroDocumento", documentoNumero);
rpt.SetParameterValue("@consultoraCodigo", consultoraCodigo);
rpt.SetParameterValue("@apellidoPaterno", apellidoPaterno);
rpt.SetParameterValue("@apellidoMaterno", apellidoMaterno);
rpt.SetParameterValue("@nombres", nombres);
if (Convert.ToInt32(ddlEstadoVerificado.SelectedValue) == 2)
rpt.SetParameterValue("@estadoVerificado", Convert.DBNull);
else
rpt.SetParameterValue("@estadoVerificado", Convert.ToBoolean(Convert.ToInt32(ddlEstadoVerificado.SelectedValue)));
if (Convert.ToInt32(ddlModoGrabacion.SelectedValue) == 2)
rpt.SetParameterValue("@modoGrabacion", Convert.DBNull);
else
rpt.SetParameterValue("@modoGrabacion", Convert.ToBoolean(Convert.ToInt32(ddlModoGrabacion.SelectedValue)));
rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "reporte_detalle_incorporaciones_" + DateFormatter.getTimestamp(DateTime.Now));
}
catch (Exception ex)
{
//System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
示例5: GH
//.........这里部分代码省略.........
dtsql2.Columns.Add("Qty");
//dtsql2.Columns.Add("ProdSellPrice");
dtsql2.Columns.Add("UnitPrice");
dtsql2.Columns.Add("SubTotal");
dtsql2.Columns.Add("pStorageSpaces");
dssql.Tables.Add(dtsql2);
using (inikierpEntities ent = new inikierpEntities())
{
var v = from eo in ent.eorder
join cus in ent.customercode on eo.cusID equals cus.cusID
join send in ent.sendcode on eo.sendID equals send.sendID
join payway in ent.paywaycode on eo.payID equals payway.payID
//join invtitle in ent.invtitlecode on eo.invTitleCode equals invtitle.invTitleCode1
where eo.odID == 62636 //&& invtitle.invTitleCode1!=0
select new
{
eo.eoDate,
eo.total,
eo.orderNo,
eo.eoMemo,
eo.invTitleCode,
eo.odID,
cus.contactName,
cus.sendAddress,
cus.contactMobile,
cus.cusID,
payway.payDesc,
send.sendName
};
int i = 0;
foreach (var h in v)
{
TextObject contactName = (TextObject)customerReport.ReportDefinition.ReportObjects["Text10"];
contactName.Text = h.contactName;
var g = from a in ent.invtitlecode
join e in ent.eorder on a.invTitleCode1 equals e.invTitleCode
where e.orderNo == h.orderNo && a.invTitleCode1 == h.invTitleCode
select new { a.invTitleDesc, a.invCode };
//int jj=g.ToList().Count();
foreach (var gg in g)
{
TextObject invCode = (TextObject)customerReport.ReportDefinition.ReportObjects["Text11"];
invCode.Text = gg.invCode;
TextObject invTitleDesc = (TextObject)customerReport.ReportDefinition.ReportObjects["Text16"];
invTitleDesc.Text = gg.invTitleDesc;
}
TextObject cusID = (TextObject)customerReport.ReportDefinition.ReportObjects["Text12"];
cusID.Text = h.cusID.ToString();
TextObject orderNo = (TextObject)customerReport.ReportDefinition.ReportObjects["Text13"];
orderNo.Text = h.orderNo;
TextObject Invoice = (TextObject)customerReport.ReportDefinition.ReportObjects["Text14"];
Invoice.Text = "發票號碼";
TextObject sendName = (TextObject)customerReport.ReportDefinition.ReportObjects["Text15"];
sendName.Text = h.sendName;
TextObject payDesc = (TextObject)customerReport.ReportDefinition.ReportObjects["Text17"];
payDesc.Text = h.payDesc;
TextObject contactMobile = (TextObject)customerReport.ReportDefinition.ReportObjects["Text25"];
contactMobile.Text = h.contactMobile;
TextObject eoDate = (TextObject)customerReport.ReportDefinition.ReportObjects["Text18"];
eoDate.Text = h.eoDate.Value.ToString("yyyy-MM-dd");
TextObject sendAddress = (TextObject)customerReport.ReportDefinition.ReportObjects["Text19"];
sendAddress.Text = h.sendAddress;
TextObject eoMemo = (TextObject)customerReport.ReportDefinition.ReportObjects["Text20"];
eoMemo.Text = h.eoMemo;
TextObject total = (TextObject)customerReport.ReportDefinition.ReportObjects["Text21"];
total.Text = h.total.ToString();
int j = 0;
var yy = from ei in ent.eorderitem
join pd in ent.productcode on ei.prodID equals pd.prodID
where ei.odID == h.odID select new
{
pd.prodSeq, pd.prodDesc, ei.qty, ei.unitPrice, pd.pStorageSpaces
};
foreach (var f in yy)
{
dssql.Tables["Eorderitem"].Rows.Add();
dssql.Tables["Eorderitem"].Rows[j]["ProdSeq"] = f.prodSeq;
dssql.Tables["Eorderitem"].Rows[j]["ProdDesc"] = f.prodDesc;
dssql.Tables["Eorderitem"].Rows[j]["Qty"] = f.qty;
dssql.Tables["Eorderitem"].Rows[j]["UnitPrice"] = f.unitPrice;
dssql.Tables["Eorderitem"].Rows[j]["SubTotal"] = f.qty * f.unitPrice;
dssql.Tables["Eorderitem"].Rows[j]["pStorageSpaces"] = f.pStorageSpaces;
j++;
}
i++;
}
}
DataView dv = new DataView();
dv = dssql.Tables["Eorderitem"].DefaultView;
customerReport.SetDataSource(dv);
this.CrystalReportViewer1.ReportSource = customerReport;
customerReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "");
}
示例6: ExportEstimacionCostos
//Exporta a Excel el grid
protected void ExportEstimacionCostos(object sender, EventArgs e)
{
string parametro = cmbClasificacion.Value.ToString();
//1. Configurar la conexión y el tipo de comando
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString);
try
{
SqlCommand comando = new SqlCommand("web_spS_ObtenerConceptosRevisados", conn);
SqlDataAdapter adaptador = new SqlDataAdapter(comando);
DataTable dt = new DataTable();
adaptador.SelectCommand.CommandType = CommandType.StoredProcedure;
adaptador.SelectCommand.Parameters.Add(@"CLASIFICACION", SqlDbType.VarChar).Value = parametro;
adaptador.Fill(dt);
ReportDocument rCaratulaEstimacionCostos = new ReportDocument();
rCaratulaEstimacionCostos.Load(Server.MapPath("reportess/rCaratulaEstimacionDeCostos.rpt"));
rCaratulaEstimacionCostos.SetDataSource(dt);
rCaratulaEstimacionCostos.SetParameterValue("pProveedor", "A & R Construcciones S.A de C.V");
rCaratulaEstimacionCostos.SetParameterValue("pathlogo", Server.MapPath(" ") + "\\images\\clientes\\");
ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions();
excelFormatOpts.ExcelUseConstantColumnWidth = false;
rCaratulaEstimacionCostos.ExportOptions.FormatOptions = excelFormatOpts;
rCaratulaEstimacionCostos.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, true, "Reportes Mantenimiento " + parametro);
}
catch (Exception ex)
{
ex.Message.ToString();
}finally{
if (conn.State != ConnectionState.Closed)
conn.Close();
conn.Dispose();
}
}
示例7: PrintReport
//dbINFO._SRV, dbINFO._CAT, dbINFO._UID, dbINFO._PWD
public void PrintReport(Page _Page, string _ReportName, string _FileName, DataTable dt)
{
ReportDocument rptDoc = new ReportDocument();
try
{
rptDoc.Load(_Page.Server.MapPath("~/Reports/" + _ReportName));
rptDoc.SetDataSource(dt);
rptDoc.SetDatabaseLogon(dbINFO._UID, dbINFO._PWD, dbINFO._SRV, dbINFO._CAT);
_Page.Response.Buffer = false;
_Page.Response.ClearContent();
_Page.Response.ClearHeaders();
//Export the Report to Response stream in PDF format and file name Customers
rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, _Page.Response, true, _FileName);
}
catch (Exception ex)
{
Utility.ShowHTMLMessage(_Page, "100", ex.Message);
}
finally
{
rptDoc.Close();
rptDoc.Dispose();
}
}
示例8: GH
public void GH()
{
customerReport = new ReportDocument();
customerReport.Load(Server.MapPath("Print_Invoice.rpt"));//Print_Invoice
DataSet dssql = new DataSet();
DataTable dtsql2 = new DataTable();
dtsql2.TableName = "Invoice";
dtsql2.Columns.Add("ProdDesc");
dtsql2.Columns.Add("Qty");
dtsql2.Columns.Add("UnitPrice");
dtsql2.Columns.Add("SubTotal");
dssql.Tables.Add(dtsql2);
using(inikierpEntities ent=new inikierpEntities())
{
//var v = from eo in ent.eorder
// join cus in ent.customercode on eo.cusID equals cus.cusID
// where eo.odID == 62636
// select new
// {
// eo.orderNo,eo.invNo
// };
//foreach(var h in v)
//{
//}
var yy = from ei in ent.eorderitem
join pd in ent.productcode on ei.prodID equals pd.prodID
where ei.odID == 62632
select new { pd.prodDesc, ei.qty, ei.unitPrice };
int j = 0;
foreach(var f in yy)
{
dssql.Tables["Invoice"].Rows.Add();
dssql.Tables["Invoice"].Rows[j]["ProdDesc"] = f.prodDesc;
dssql.Tables["Invoice"].Rows[j]["Qty"] = f.qty;
dssql.Tables["Invoice"].Rows[j]["UnitPrice"] = f.unitPrice;
dssql.Tables["Invoice"].Rows[j]["SubTotal"] = f.qty * f.unitPrice;
j++;
}
}
DataView dv = new DataView();
dv = dssql.Tables["Invoice"].DefaultView;
customerReport.SetDataSource(dv);
this.CrystalReportViewer1.ReportSource = customerReport;
customerReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "");
}
示例9: gvReingresos_RowCommand
protected void gvReingresos_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "generatePDFView")
{
String reingresoID = gvReingresos.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text;
String consultoraID = gvReingresos.Rows[Convert.ToInt32(e.CommandArgument)].Cells[1].Text;
try
{
String db_databaseName = connectionBL.getDataBaseName();
String db_serverName = connectionBL.getServerName();
String db_userID = connectionBL.getUserID();
String db_password = connectionBL.getPassword();
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("../CrystalReports/crReingreso.rpt"));
rpt.SetDatabaseLogon("", "", ".", db_databaseName);
rpt.SetParameterValue("@reingresoID", Convert.ToInt32(reingresoID));
rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Reingreso_" + DateFormatter.getTimestamp(DateTime.Now));
}
catch (Exception ex)
{
//System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
}
示例10: muestrareporte
//.........这里部分代码省略.........
dtVoucher.Columns.Add("MonedaDescripcion2");
dtVoucher.Columns.Add("SimboloMoneda2");
dtVoucher.Columns.Add("EmailEnviaVoucher");
try
{
System.Data.SqlClient.SqlConnection conn;
conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
conn.Open();
SqlCommand command = new SqlCommand("spselImprimeVoucher", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("Id_Operacion", Convert.ToInt32(IdOperacion));
command.ExecuteNonQuery();
adapter = new SqlDataAdapter(command);
adapter.Fill(ds);
conn.Close();
ds.Dispose();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
DataRow row = dtVoucher.NewRow();
row["IdOperacion"] = ds.Tables[0].Rows[i]["IdOperacion"].ToString();
row["FechaEmision"] = ds.Tables[0].Rows[i]["FechaEmision"].ToString(); ;
row["NroVoucher"] = ds.Tables[0].Rows[i]["NroVoucher"].ToString();
row["Pasajero_Nombre"] = ds.Tables[0].Rows[i]["Pasajero_Nombre"].ToString();
row["Pasajero_Apellido"] = ds.Tables[0].Rows[i]["Pasajero_Apellido"].ToString();
row["Pasajero_Documento"] = ds.Tables[0].Rows[i]["Pasajero_Documento"].ToString();
row["Pasajero_FechaNac"] = ds.Tables[0].Rows[i]["Pasajero_FechaNac"].ToString();
row["Pasajero_TipoTelefono"] = ds.Tables[0].Rows[i]["Pasajero_TipoTelefono"].ToString();
row["Pasajero_Telefono"] = ds.Tables[0].Rows[i]["Pasajero_Telefono"].ToString();
row["Pasajero_Celular"] = ds.Tables[0].Rows[i]["Pasajero_Celular"].ToString();
row["Pasajero_Email"] = ds.Tables[0].Rows[i]["Pasajero_Email"].ToString();
row["ContactoEmergencia_Apellido"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Apellido"].ToString();
row["ContactoEmergencia_Nombre"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Nombre"].ToString();
row["ContactoEmergencia_Email"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Email"].ToString();
row["ProductoDescripcion"] = ds.Tables[0].Rows[i]["ProductoDescripcion"].ToString();
row["OrigenDescripcion"] = ds.Tables[0].Rows[i]["OrigenDescripcion"].ToString();
row["DestinoDescripcion"] = ds.Tables[0].Rows[i]["DestinoDescripcion"].ToString();
row["FechaPartida"] = ds.Tables[0].Rows[i]["FechaPartida"].ToString();
row["FechaRegreso"] = ds.Tables[0].Rows[i]["FechaRegreso"].ToString();
row["ImporteTarifaPesos"] = ds.Tables[0].Rows[i]["ImporteTarifaPesos"].ToString();
row["ImporteTarifaDolar"] = ds.Tables[0].Rows[i]["ImporteTarifaDolar"].ToString();
row["IdCobertura"] = ds.Tables[0].Rows[i]["IdCobertura"].ToString();
row["DescripcionCobertura"] = ds.Tables[0].Rows[i]["DescripcionCobertura"].ToString();
row["ValorCobertura"] = ds.Tables[0].Rows[i]["ValorCobertura"].ToString();
row["MonedaDescripcion"] = ds.Tables[0].Rows[i]["MonedaDescripcion"].ToString();
row["SimboloMoneda"] = ds.Tables[0].Rows[i]["SimboloMoneda"].ToString();
row["IdCobertura2"] = ds.Tables[0].Rows[i]["IdCobertura2"].ToString();
row["DescripcionCobertura2"] = ds.Tables[0].Rows[i]["DescripcionCobertura2"].ToString();
row["ValorCobertura2"] = ds.Tables[0].Rows[i]["ValorCobertura2"].ToString();
row["MonedaDescripcion2"] = ds.Tables[0].Rows[i]["MonedaDescripcion2"].ToString();
row["SimboloMoneda2"] = ds.Tables[0].Rows[i]["SimboloMoneda2"].ToString();
row["EmailEnviaVoucher"] = ds.Tables[0].Rows[i]["EmailEnviaVoucher"].ToString();
emailenviavoucher = ds.Tables[0].Rows[i]["EmailEnviaVoucher"].ToString();
dtVoucher.Rows.Add(row);
}
ds.Dispose();
dsVoucher.Tables.Add(dtVoucher);
ReportDocument reporte = new ReportDocument(); // creating object of crystal report
reporte.Load(Server.MapPath("~/Reportes/pagoconfirmado.rpt")); // path of report
reporte.SetDataSource(dsVoucher.Tables[0]);
dsVoucher.Dispose();
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
reporte.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
reporte.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
archivo = "C:/Data/Tusegurodeviaje/Reports/TempReports/pagoconfirmado_" + IdOperacion + ".pdf";
diskOpts.DiskFileName = archivo;
reporte.ExportOptions.DestinationOptions = diskOpts;
reporte.Export();
CrystalReportViewer1.ReportSource = reporte;
reporte.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "pagoconfirmado" + IdOperacion);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
}
}
示例11: gvIncorporaciones_RowCommand
protected void gvIncorporaciones_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "generatePDFView")
{
String incorporacionID = gvIncorporaciones.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text;
String consultoraID = gvIncorporaciones.Rows[Convert.ToInt32(e.CommandArgument)].Cells[1].Text;
String db_databaseName = connectionBL.getDataBaseName();
String db_serverName = connectionBL.getServerName();
String db_userID = connectionBL.getUserID();
String db_password = connectionBL.getPassword();
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("../CrystalReports/rcSolicitudCredito.rpt"));
rpt.SetDatabaseLogon("", "", ".", db_databaseName);
rpt.SetParameterValue("@incorporacionID", Convert.ToInt32(incorporacionID));
rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "solicitud_de_credito_" + DateFormatter.getTimestamp(DateTime.Now));
}
}
示例12: ShowReportAll
/// <summary>
///
/// </summary>
private void ShowReportAll()
{
ReportDocument crystalReport = new ReportDocument();
crystalReport.Load(Server.MapPath(@"Reports\Report\\" + _reportName));
Session["ReportDocument"] = crystalReport;
crystalReport.Database.Tables["BillMaster"].SetDataSource(_ds.Tables[0]);
crystalReport.Database.Tables["Company"].SetDataSource(_ds.Tables[1]);
//crystalReport.SetDataSource(_ds);
rptViewer.PrintMode = PrintMode.Pdf;
//rptViewer.
crystalReport.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
rptViewer.ReportSource = (ReportDocument)Session["ReportDocument"];
rptViewer.RefreshReport();
rptViewer.DataBind();
// Stop buffering the response
Response.Buffer = false;
// Clear the response content and headers
Response.ClearContent();
Response.ClearHeaders();
ExportFormatType format = ExportFormatType.PortableDocFormat;
string ext = ".pdf";
string reportName = "myreport";
try
{
crystalReport.ExportToHttpResponse(format, Response, false, "");
}
catch (System.Threading.ThreadAbortException)
{
//ThreadException can happen for internale Response implementation
}
catch (Exception ex)
{
//other exeptions will be managed
throw;
}
}
示例13: muestrareporte
//.........这里部分代码省略.........
conn.Close();
ds.Dispose();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
DataRow row = dtVoucher.NewRow();
row["IdOperacion"] = ds.Tables[0].Rows[i]["IdOperacion"].ToString();
row["FechaEmision"] = ds.Tables[0].Rows[i]["FechaEmision"].ToString(); ;
row["NroVoucher"] = ds.Tables[0].Rows[i]["NroVoucher"].ToString();
row["Pasajero_Nombre"] = ds.Tables[0].Rows[i]["Pasajero_Nombre"].ToString();
row["Pasajero_Apellido"] = ds.Tables[0].Rows[i]["Pasajero_Apellido"].ToString();
row["Pasajero_Documento"] = ds.Tables[0].Rows[i]["Pasajero_Documento"].ToString();
row["Pasajero_FechaNac"] = ds.Tables[0].Rows[i]["Pasajero_FechaNac"].ToString();
row["Pasajero_TipoTelefono"] = ds.Tables[0].Rows[i]["Pasajero_TipoTelefono"].ToString();
row["Pasajero_Telefono"] = ds.Tables[0].Rows[i]["Pasajero_Telefono"].ToString();
row["Pasajero_Celular"] = ds.Tables[0].Rows[i]["Pasajero_Celular"].ToString();
row["Pasajero_Email"] = ds.Tables[0].Rows[i]["Pasajero_Email"].ToString();
row["ContactoEmergencia_Apellido"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Apellido"].ToString();
row["ContactoEmergencia_Nombre"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Nombre"].ToString();
row["ContactoEmergencia_Email"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Email"].ToString();
row["ProductoDescripcion"] = ds.Tables[0].Rows[i]["ProductoDescripcion"].ToString();
row["OrigenDescripcion"] = ds.Tables[0].Rows[i]["OrigenDescripcion"].ToString();
row["DestinoDescripcion"] = ds.Tables[0].Rows[i]["DestinoDescripcion"].ToString();
row["FechaPartida"] = ds.Tables[0].Rows[i]["FechaPartida"].ToString();
row["FechaRegreso"] = ds.Tables[0].Rows[i]["FechaRegreso"].ToString();
row["ImporteTarifaPesos"] = ds.Tables[0].Rows[i]["ImporteTarifaPesos"].ToString();
row["ImporteTarifaDolar"] = ds.Tables[0].Rows[i]["ImporteTarifaDolar"].ToString();
row["IdCobertura"] = ds.Tables[0].Rows[i]["IdCobertura"].ToString();
row["DescripcionCobertura"] = ds.Tables[0].Rows[i]["DescripcionCobertura"].ToString();
row["ValorCobertura"] = ds.Tables[0].Rows[i]["ValorCobertura"].ToString();
row["MonedaDescripcion"] = ds.Tables[0].Rows[i]["MonedaDescripcion"].ToString();
row["SimboloMoneda"] = ds.Tables[0].Rows[i]["SimboloMoneda"].ToString();
row["IdCobertura2"] = ds.Tables[0].Rows[i]["IdCobertura2"].ToString();
row["DescripcionCobertura2"] = ds.Tables[0].Rows[i]["DescripcionCobertura2"].ToString();
row["ValorCobertura2"] = ds.Tables[0].Rows[i]["ValorCobertura2"].ToString();
row["MonedaDescripcion2"] = ds.Tables[0].Rows[i]["MonedaDescripcion2"].ToString();
row["SimboloMoneda2"] = ds.Tables[0].Rows[i]["SimboloMoneda2"].ToString();
dtVoucher.Rows.Add(row);
}
ds.Dispose();
dsVoucher.Tables.Add(dtVoucher);
ReportDocument reporte = new ReportDocument(); // creating object of crystal report
reporte.Load(Server.MapPath("pagoconfirmado.rpt")); // path of report
reporte.SetDataSource(dsVoucher.Tables[0]);
CrystalReportViewer1.ReportSource = reporte;
reporte.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "pagoconfirmado" + IdOperacion);
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
reporte.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
reporte.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
//archivo = Server.MapPath("TempReports/pagoconfirmado" + IdOperacion + ".pdf");
archivo = "C:/Data/Tusegurodeviaje/Reports/TempReports/pagoconfirmado" + IdOperacion + ".pdf";
diskOpts.DiskFileName = archivo;
reporte.ExportOptions.DestinationOptions = diskOpts;
reporte.Export();
MailMessage mail = new MailMessage();
//set the addresses
string emailAddressList = System.Configuration.ConfigurationManager.AppSettings["emailsToSend"];
string displayName = System.Configuration.ConfigurationManager.AppSettings["displayNameEmailAddressToSendAuthorizationDocs"];
mail.From = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["fromEmailAddressToSendAuthorizationDocs"], displayName);
mail.To.Add(emailAddressList);
mail.IsBodyHtml = true;
//set the content
mail.Subject = "Pago Pendiente";
//set the body
mail.Body += "Muchas gracias.<br />";
//MailAttachment objArchivo = new MailAttachment("E:\\Email\\pedido.pdf");
mail.Attachments.Add(new Attachment(archivo));
//mail.Attachments.Add(archivo);
string SMTPServer = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"];
SmtpClient smtp = new SmtpClient(SMTPServer); //specify the mail server address
smtp.Send(mail);
dsVoucher.Dispose();
}
catch (Exception ex)
{
lblError.Text = "Error " + ex.Message;
}
finally
{
}
}
示例14: ShowRptData
public void ShowRptData()
{
try
{
string strReportName = System.Web.HttpContext.Current.Session["ReportName"].ToString();
string cardCode = System.Web.HttpContext.Current.Session["CardCode"].ToString();
string cardName = System.Web.HttpContext.Current.Session["CardName"].ToString();
string startDate = System.Web.HttpContext.Current.Session["StartDate"].ToString();
string endDate = System.Web.HttpContext.Current.Session["EndDate"].ToString();
ReportDocument rd = new ReportDocument();
string strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Report//" + strReportName;
ExceptionLog.Write(string.Format("the report path is {0}", strRptPath));
rd.Load(strRptPath);
TableLogOnInfo logInfo = new TableLogOnInfo();
logInfo.ConnectionInfo.ServerName = ".";
logInfo.ConnectionInfo.DatabaseName = "SBO_GS_TEST";
logInfo.ConnectionInfo.UserID = "sa";
logInfo.ConnectionInfo.Password = "avatech";
rd.Database.Tables[0].ApplyLogOnInfo(logInfo);
if (!string.IsNullOrEmpty(cardName))
rd.SetParameterValue("cardname", cardName);
if (!string.IsNullOrEmpty(startDate))
rd.SetParameterValue("Sdate", Convert.ToDateTime(startDate));
if (!string.IsNullOrEmpty(startDate))
rd.SetParameterValue("Edate", Convert.ToDateTime(endDate));
rd.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "crReport");
Session["ReportName"] = null;
Session["CardCode"] = null;
Session["CardName"] = null;
Session["StartDate"] = null;
Session["EndDate"] = null;
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
示例15: imprimepresupuesto
private void imprimepresupuesto()
{
String opciones;
String[] Datos;
SqlConnection connection;
SqlDataAdapter adapter;
try
{
DataSet dspresupuesto= new DataSet();
opciones = Request.QueryString["op"];
Datos = opciones.Split('_');
System.Data.SqlClient.SqlConnection conn;
conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
conn.Open();
SqlCommand command = new SqlCommand("spselImprimeCotizacion", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("FechaDesde", Datos[0].ToString());
command.Parameters.AddWithValue("FechaHasta", Datos[1].ToString());
command.Parameters.AddWithValue("idOrigen", Datos[2].ToString());
command.Parameters.AddWithValue("IdDestino", Datos[3].ToString() );
command.Parameters.AddWithValue("Email", Datos[4].ToString());
command.Parameters.AddWithValue("edades", Datos[5].ToString());
command.ExecuteNonQuery();
adapter = new SqlDataAdapter(command);
adapter.Fill(dspresupuesto);
conn.Close();
String archivo = "";
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("~/Reportes/presupuesto1.rpt"));
rptDoc.SetDataSource(dspresupuesto.Tables[0]);
dspresupuesto.Dispose();
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
string targetFileName = "C:/Data/Tusegurodeviaje/Reports/TempReports/presupuesto_" + (new Random()).Next() + ".pdf";
//string targetFileName = Request.PhysicalApplicationPath + "C:\Data\Tusegurodeviaje\Reports\TempReports\\presupuesto" + (new Random()).Next() + ".pdf";
rptDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
rptDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
diskOpts.DiskFileName = targetFileName;
//archivo = Server.MapPath(targetFileName);
rptDoc.ExportOptions.DestinationOptions = diskOpts;
// Export report ... Server-Side.
rptDoc.Export();
CrystalReportViewer1.ReportSource = rptDoc;
rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "presupuesto");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
}
}