水晶报告excel文件不会被复制到asp.net中的目标文件夹 [英] the crystal report excel file does not get copied to the target folder in asp.net

查看:82
本文介绍了水晶报告excel文件不会被复制到asp.net中的目标文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当运行抛出代码excel文件生成但是当部署在服务器文件上时没有在指定的路径上生成但是文件夹被创建,存储过程也返回数据....请帮助





DataTable _dt = MyData.GetDataSet(spName,para,0).Tables [0];



if(_dt.Rows.Count> 0)

{

FileName =//\"+FileName+\".xls;

< br $>
rep_doc.Load(FilePath);

rep_doc.Refresh();

rep_doc.SetDataSource(_dt);

rep_doc.SetParameterValue(FromDate,txtFromDate.Text.Trim());

rep_doc.SetParameterValue(ToDate,txtToDate.Text.Trim());



string FinalPath = path + FileName;



rep_doc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel,FinalPath);

When run throw code excel file gets generated but when deployed on server file does not get generated on the specified path but folder are created,stored procedure also returns data .... please help


DataTable _dt = MyData.GetDataSet(spName, para, 0).Tables[0];

if (_dt.Rows.Count > 0)
{
FileName = "//"+FileName+".xls";

rep_doc.Load(FilePath);
rep_doc.Refresh();
rep_doc.SetDataSource(_dt);
rep_doc.SetParameterValue("FromDate", txtFromDate.Text.Trim());
rep_doc.SetParameterValue("ToDate", txtToDate.Text.Trim());

string FinalPath = path + FileName;

rep_doc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, FinalPath);

推荐答案

您的代码在服务器上运行 。您正在将报告导出到服务器上的文件



如果您希望在客户端上保存的Excel文件,然后你必须把文件写到 Response 。然后用户可以选择保存位置。



而不是使用 ExportToDisk ,使用 ExportToHttpResponse 方法 [ ^ ]:

Your code is running on the server. You are exporting the report to a file on the server.

If you want the Excel file to be saved on the client, then you have to write the file to the Response. The user will then be able to choose where to save it.

Rather than using ExportToDisk, use the ExportToHttpResponse method[^]:
if (_dt.Rows.Count > 0)
{
    FileName = FileName + ".xls";
    
    rep_doc.Load(FilePath);
    rep_doc.Refresh();
    rep_doc.SetDataSource(_dt);
    rep_doc.SetParameterValue("FromDate", txtFromDate.Text.Trim());
    rep_doc.SetParameterValue("ToDate", txtToDate.Text.Trim());
    
    rep_doc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, true, FileName);
}


这篇关于水晶报告excel文件不会被复制到asp.net中的目标文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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