网络上提到的方法 大概" />
乔山办公网我们一直在努力
您的位置:乔山办公网 > word文档 > 为什么<em>水晶报表</em>能够导出rpt,<em>word</em>

为什么<em>水晶报表</em>能够导出rpt,<em>word</em>

作者:乔山办公网日期:

返回目录:word文档


你可以用finereport报表软件导出试试。

原来的报表:

导出后:



网络上提到的方法 大概有以下:

1、如果你使用VS2005,可以使用RDLC报表,导出的Excel效果十分好。

2、可以考虑用文本框代替线。

3、

水晶报表自带的e799bee5baa6e79fa5e98193e58685e5aeb9332导出Excel不太完美,导出的文件没有网格线,要使它出现网格线就要自己写导出方法.要注意的一点是只有用强类型的水晶报表才可以写自定义的导出方法(个人意见)。方法步骤:
1, 创建个数据集
2, 在业务层创建水晶报表文件(强类型水晶报表就是把水晶报表放在项目里面,而不是网站里,这样在界面可以调用报表文件相关的方法)
3, 报表绑定:
在方法前面声明必要的参数

ReportDocument ReportDoc;

TableLogOnInfo logOnInfo;

DiskFileDestinationOptions FileOPS;

ExportOptions ExOPS;

CrystalReport1 cr = new CrystalReport1();

绑定代码:

DataSet1 ds = new DataSet1();

SqlConnection con = new SqlConnection("server=YWG;uid=sa;pwd=;database=jcjyzbxj");

SqlDataAdapter da = new SqlDataAdapter("SELECT DM,MC FROM DM_XB", con);

da.Fill(ds, "DM_XB");

cr.SetDataSource(ds);

CrystalReportViewer1.ReportSource = cr;

导出Excel代码:

调用Excel的方法:

protected void Button1_Click(object sender, EventArgs e)

{

DataSet1 ds = new DataSet1();

SqlConnection con = new SqlConnection("server=YWG;uid=sa;pwd=;database=jcjyzbxj");

SqlDataAdapter da = new SqlDataAdapter("SELECT DM,MC FROM DM_XB", con);

da.Fill(ds, "DM_XB");

cr.SetDataSource(ds);

CrystalReportViewer1.ReportSource = cr;

string ReportFile = Server.MapPath("CrystalReport1.rpt");

string ExcelFileName = "g:\\myExcel.xls";

bool msg= ExportToExcel(ReportFile, ds, ExcelFileName);

}

导出Excel的方法:

public bool ExportToExcel(string ReportFile, object ReportDataSource, string ExcelFileName)

{

try

{

ReportDoc = new ReportDocument();

logOnInfo = new TableLogOnInfo();

FileOPS = new DiskFileDestinationOptions();

cr.Load(ReportFile);

cr.SetDataSource(ReportDataSource);

FileOPS.DiskFileName = ExcelFileName;

ExOPS = cr.ExportOptions;

ExOPS.DestinationOptions = FileOPS;

ExOPS.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;

ExOPS.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.ExcelRecord;

cr.Export();

System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response;

Response.ClearContent();

Response.ClearHeaders();

//Response.ContentType = contentType;

//Response.WriteFile(ExcelFileName);

Response.Flush();

Response.Close();

return true;

}

catch

{

return false;

}

}

需要注意的地方:1在导出Excel以前一定要重新绑定一次数据,要不导出的文件没有数据

2导出Excel的文件类型要是ExcelRecord,不能是Excel否则一样没有网格线
还有看下软件有没有问题
你这个报表文件是用哪个版本报表做成的?要是很老的话64位不支持肯定报错。有的水晶报表就没有对应64机器哦。

1、进入windows7系统的控制面板->区域和语言->格式

2、只要不是“中文(简体,中国)”的就可以了,连注销重启都不用,就可以正常导出word格式了,题主你试试看这种方法呢。

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网