将水晶报告导出为特定文件夹中的pdf格式。 [英] Export crystal report to pdf format in the particular folder.

查看:57
本文介绍了将水晶报告导出为特定文件夹中的pdf格式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有



我想将水晶报告导出为pdf格式。

以下代码有效。

唯一的问题是如何指定保存文件的文件夹。

< pre lang =c#> protected void Button1_Click( object sender,EventArgs e)
{
test.Load(Server.MapPath( tiredata.rpt));

mydbconn mycon = new mydbconn();
mycon.DBCreate();
DataSet3 dsobj = new DataSet3();

string query = SELECT serialno FROM TIM_TIRE_SIZE;

OracleDataAdapter myOracleDataAdapter1 = new OracleDataAdapter(query,mycon.conn);

myOracleDataAdapter1.Fill(dsobj, tbl3);

test.SetDataSource(dsobj);

CrystalReportViewer1.ReportSource = test;

CrystalReportViewer1.DataBind();
oStream =(MemoryStream)

test.ExportToStream(ExportFormatType.PortableDocFormat);

Response.Clear();

Response.Buffer = true ;

Response.ContentType = application / pdf;

Response.BinaryWrite(oStream.ToArray());

ExportFormatType formatType = ExportFormatType.NoFormat;
formatType = ExportFormatType.PortableDocFormat;

test.ExportToHttpResponse(formatType,Response, true 吉瑞);

Response.End();

oStream.Close();
mycon.DBclose();

ClientScript.RegisterStartupScript(GetType(), 消息 < SCRIPT LANGUAGE ='javascript'> alert('ok');< / script> );
}

解决方案

你不能。在服务器上运行的代码无法控制客户端保存文件的位置 - 甚至是什么。



在你问之前,不,没有解决方法。如果有,那将是一个主要的安全漏洞。


Dear All

I want to export crystal report to pdf format.
Following code works.
Only thing is how can I specify the folder to save the file.

protected void Button1_Click(object sender, EventArgs e)
{
    test.Load(Server.MapPath("tiredata.rpt"));

    mydbconn mycon = new mydbconn();
    mycon.DBCreate();
    DataSet3 dsobj = new DataSet3();
    
    string query = "SELECT serialno FROM  TIM_TIRE_SIZE ";
    
    OracleDataAdapter myOracleDataAdapter1 = new OracleDataAdapter(query, mycon.conn);

    myOracleDataAdapter1.Fill(dsobj, "tbl3");

    test.SetDataSource(dsobj);

    CrystalReportViewer1.ReportSource = test;

    CrystalReportViewer1.DataBind();
    oStream = (MemoryStream)

    test.ExportToStream(ExportFormatType.PortableDocFormat);

    Response.Clear();

    Response.Buffer = true;

    Response.ContentType = "application/pdf";

    Response.BinaryWrite(oStream.ToArray());

ExportFormatType formatType = ExportFormatType.NoFormat;  
    formatType = ExportFormatType.PortableDocFormat; 
   
    test.ExportToHttpResponse(formatType, Response, true, "giri");

    Response.End();

    oStream.Close();
    mycon.DBclose();      
    
    ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('ok');</script>");
}

解决方案

You can't. Code running on the server has no control over where - or even if - the client saves a file.

And before you ask, no, there is no workaround. If there was, it would be a major security vulnerability.


这篇关于将水晶报告导出为特定文件夹中的pdf格式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆