只有30分了: 水晶报表导出到excel的问题!

xiaomaoxia 2005-08-17 11:25:09
如果 报表的 某些列 的标题 有两行 , 导出到excel 的时候就会引起标题的格式错乱,有些标题都没了, 这是怎么回事呢??

如果标题只是一行的话就没问题!!!
...全文
175 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
iceqings 2005-08-26
  • 打赏
  • 举报
回复
按这个程序来做,就OK了!


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;//
using CrystalDecisions.CrystalReports.Engine;//
using CrystalDecisions.Shared;//

namespace Web
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
try
{
string filename;
ReportDocument CrReportDocument=new ReportDocument();
CrReportDocument.Load(Server.MapPath("CrystalReport1.rpt"));
filename=Server.MapPath("asp.XLS");
//***************************************************************************************
CrystalReport1 oRpt=new CrystalReport1();
DataSet1 ds = new DataSet1();
SqlConnection myConn=new SqlConnection("server=Localhost;uid=sa;pwd=sql;database=sqly92");
string strSql = "select * from tt_order0";
myConn.Open();//显式打开
SqlDataAdapter myDa=new SqlDataAdapter(strSql,myConn);
myDa.Fill(ds,"tt_order0");
oRpt.SetDataSource(ds);
//CrystalReportViewer1.ReportSource = oRpt;//显示报表
//***************************************************************************************
CrReportDocument.SetDataSource(ds);

DiskFileDestinationOptions CrDiskFileDestinationOptions=new DiskFileDestinationOptions();
ExportOptions CrExportOptions=new ExportOptions();
CrDiskFileDestinationOptions.DiskFileName=filename;
CrExportOptions=CrReportDocument.ExportOptions;
CrExportOptions.DestinationOptions=CrDiskFileDestinationOptions;
CrExportOptions.ExportDestinationType=ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType=ExportFormatType.Excel;
CrReportDocument.Export();
//把转换的文件送到客户端
//Response.ContentType="Application/xls";
//Response.WriteFile("asp.XLS",true);
//Response.End();
myConn.Close();//显式关闭
Response.Write("<script language=javascript>alert('" + "成功写入" + "');</script>");
}
catch(Exception ex)
{
Response.Write("<script language=javascript>alert('" + ex.Message + "');</script>");
}

}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}
xiaomaoxia 2005-08-26
  • 打赏
  • 举报
回复
楼上的, 你嫂嫂一下,
xiaomaoxia 2005-08-26
  • 打赏
  • 举报
回复
多谢楼上的, 我试试, 另外, 我是在window 编程, 不是web应用程序
iceqings 2005-08-26
  • 打赏
  • 举报
回复
大家来QQ群里讨论吧,我找了几个比较好的技术群,大家分享一下!

C#.net 梦想:QQ群:群号:9700396

C#.net 开发:QQ群:群号:9715298

C# Windows 程序设计:QQ群:群号:14407665

C#.Net 学习:QQ群:群号:2448263

.net+水晶报表群:QQ群:群号:14819489
iceqings 2005-08-26
  • 打赏
  • 举报
回复
这个会自动生成.xls的文件,

如果你要显式保存,就要修改一下了,

这个程序生成的xls文件在你的程序文件夹里

叫asp.xls

你也可以修改成自已的文件名,呵呵!可以结帖了!!!!!!!
xiaomaoxia 2005-08-24
  • 打赏
  • 举报
回复
楼上的, 我用水晶报表10企业版! 你用的哪个版本, 我的就是出现那个问题
jhpu2000 2005-08-24
  • 打赏
  • 举报
回复
哦,水晶10我没有用过,我用的是VS.NET 2003 自带的

另:水晶10是买的吗?若不是,哪儿可以下破解的啊,我想看看
jhpu2000 2005-08-23
  • 打赏
  • 举报
回复
不会出现这样的问题啊,楼主存储的格式是否有误?
xiaomaoxia 2005-08-18
  • 打赏
  • 举报
回复
只导出数据!!! 不是导出格式的那个
幽云阿飞 2005-08-17
  • 打赏
  • 举报
回复
你是用什么方法导的?

4,819

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧