使用记事本中的特定行中的每个报表记录将Crystal报表导出到记事本文件中 [英] Export Crystal Report into Notepad File with Each Report Record in Specific Row in Notepad

查看:92
本文介绍了使用记事本中的特定行中的每个报表记录将Crystal报表导出到记事本文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#编码生成一个cystal报告,我希望在Notepad文件中导出记事本文件的特定行中的每个Crystal Report记录。

我在做什么?



 rptEmployeeOPRCreditReport SCR =  new  rptEmployeeOPRCreditReport(); 
SCR.SetDataSource(ds);
SCR.VerifyDatabase();

SCR.SetParameterValue( pKey,pKey);
SCR.SetParameterValue( WType,WType);
SCR.SetParameterValue( Reff,Reff);
SCR.SetParameterValue( dtFrom,StrStartDate);
SCR.SetParameterValue( dtTo,StrLastDate);
crystalReportViewer1.ReportSource = SCR;

ExportOptions ExOpt = new ExportOptions();
ExOpt.ExportFormatType = ExportFormatType.RichText;
ExOpt.ExportDestinationType = ExportDestinationType.DiskFile;
DiskFileDestinationOptions destination = new DiskFileDestinationOptions();
destination = ExportOptions.CreateDiskFileDestinationOptions();
string strFileName = OPR + strCurrentMonth + strCurrentYear + 。txt;
destination.DiskFileName = d:\\ + strFileName;
ExOpt.ExportDestinationOptions = destination;
SCR.Export(ExOpt);



它创建一个记事本文件但文件中的数据对我来说是不可理解的。 PLZ HELP ANY ONE。

解决方案

您正在输出为RTF格式。这是一个.rtf文件而不是.txt。记事本不能很好地读取.rtf。



您可以将其导出为文本类型,也可以将其保存为.rtf,然后使用写字板而不是记事本打开文件。

 con.Open(); 
string MemberQuery1 = 选择CategoryNumber,语言,MemberDetails中的MemberCode,Title,MemberName,MemberAddress1,MemberAddress2,MemberAddress3,City,PinCode,State,MemberEmailID,ClubCode,其中(RecordStatus ='A'或RecordStatus ='U')和CategoryNumber ='6',Language ='E'按会员代码ASC订购;
SqlDataAdapter da = new SqlDataAdapter(MemberQuery1,con);
DataTable dt = new DataTable();
dt.TableName = MemberDetails;
da.Fill(dt);
// ds.Tables [0] .Merge(dt);
使用 var rd = new ReportDocument( ))
{
string ClubCode = INDIVIDUALENGLISH;
// ReportDocument rd = new ReportDocument();
rd.Load( Server.MapPath( LabelReport.rpt));
// rd.Load(Server.MapPath(\\CystalReportsApp \\ CompanyDetails。 rpt));

rd.SetDataSource(dt);
// 会话[报告] = rd;
crsvLabelGeneration.ReportSource = rd;
crsvLabelGeneration.RefreshReport();
crsvLabelGeneration.DataBind();
ExportOptions eo = new ExportOptions();

TextFormatOptions pr = ExportOptions.CreateTextFormatOptions();

// HTMLFormatOptions pr = ExportOptions.CreateHTMLFormatOptions();
// PdfRtfWordFormatOptions pr = ExportOptions.CreatePdfRtfWordFormatOptions();
DiskFileDestinationOptions df = ExportOptions.CreateDiskFileDestinationOptions ();
// pr.UsePageRange = false;
eo.ExportFormatOptions = pr;
eo.ExportFormatType = ExportFormatType.TabSeperatedText;
df.DiskFileName = D:\\IndividualEnglish \\ + ClubCode + + TXT
eo.ExportDestinationOptions = df;
eo.ExportDestinationType = ExportDestinationType.DiskFile;
rd.Export(eo);

string currpath = d:\\IndividualEnglish\\;
FileInfo file = new FileInfo(currpath + + ClubCode + .txt);

string name = file.Name.Substring( 0 ,file.Name .LastIndexOf( ));

TextReader reader = new StreamReader(currpath + + ClubCode + .txt);













它创建记事本文件但文件中的数据 可以理解给我。但不要对齐行和列
PLZ帮助任何一个


I am Generating a cystal Report in C# coding that i want to Export in Notepad File with each Crystal Report Record in Specific Row of Notepad file.
what i m doing is ?

rptEmployeeOPRCreditReport SCR = new rptEmployeeOPRCreditReport();
SCR.SetDataSource(ds);
SCR.VerifyDatabase();

SCR.SetParameterValue("pKey", pKey);
SCR.SetParameterValue("WType", WType);
SCR.SetParameterValue("Reff", Reff);
SCR.SetParameterValue("dtFrom", StrStartDate);
SCR.SetParameterValue("dtTo", StrLastDate);
crystalReportViewer1.ReportSource = SCR;

ExportOptions ExOpt = new ExportOptions();
ExOpt.ExportFormatType = ExportFormatType.RichText;
ExOpt.ExportDestinationType = ExportDestinationType.DiskFile;
DiskFileDestinationOptions destination = new DiskFileDestinationOptions();
destination = ExportOptions.CreateDiskFileDestinationOptions();
string strFileName = "OPR" + strCurrentMonth + strCurrentYear + ".txt";
destination.DiskFileName = "d:\\" + strFileName;
ExOpt.ExportDestinationOptions = destination;
SCR.Export(ExOpt);


It Creates a Notepad File But the data in file is not Understandable to me. PLZ HELP ANY ONE.

解决方案

You are outputting to a Rich Text format. That's a .rtf file not a .txt. Notepad doesn't read .rtf very well.

You can either export it instead as a Text type, or you could save it as a .rtf and then open the file using WordPad instead of Notepad.


con.Open();
     string MemberQuery1 = "select CategoryNumber,Language,MemberCode,Title,MemberName,MemberAddress1,MemberAddress2,MemberAddress3,City,PinCode,State,MemberEmailID,ClubCode from MemberDetails where (RecordStatus='A' or RecordStatus='U') and CategoryNumber='6' and Language='E' ORDER BY MemberCode ASC";
    SqlDataAdapter da = new SqlDataAdapter(MemberQuery1,con);
     DataTable dt = new DataTable();
     dt.TableName = "MemberDetails";
    da.Fill(dt);
    //ds.Tables[0].Merge(dt);
    using (var rd = new ReportDocument())
    {
        string ClubCode="INDIVIDUALENGLISH";
        //ReportDocument rd = new ReportDocument();
        rd.Load(Server.MapPath("LabelReport.rpt"));
        //rd.Load(Server.MapPath("\\CystalReportsApp\\MemberDetails.rpt"));
      
        rd.SetDataSource(dt);
        //Session["Report"] = rd;
        crsvLabelGeneration.ReportSource = rd;
        crsvLabelGeneration.RefreshReport();
        crsvLabelGeneration.DataBind();
        ExportOptions eo = new ExportOptions();

        TextFormatOptions pr = ExportOptions.CreateTextFormatOptions();

        //HTMLFormatOptions pr = ExportOptions.CreateHTMLFormatOptions();
        //PdfRtfWordFormatOptions pr = ExportOptions.CreatePdfRtfWordFormatOptions();
        DiskFileDestinationOptions df = ExportOptions.CreateDiskFileDestinationOptions();
        //pr.UsePageRange = false;
        eo.ExportFormatOptions = pr;
        eo.ExportFormatType = ExportFormatType.TabSeperatedText;
        df.DiskFileName = "D:\\IndividualEnglish\\" + ClubCode + "" + ".txt";
        eo.ExportDestinationOptions = df;
        eo.ExportDestinationType = ExportDestinationType.DiskFile;
        rd.Export(eo);

        string currpath = "D:\\IndividualEnglish\\";
        FileInfo file = new FileInfo(currpath + "" + ClubCode + ".txt");

        string name = file.Name.Substring(0, file.Name.LastIndexOf("."));

       TextReader reader = new StreamReader(currpath + "" + ClubCode + ".txt");







It Creates a Notepad File But the data in file is Understandable to me.But not to align Row and column
PLZ HELP ANY ONE


这篇关于使用记事本中的特定行中的每个报表记录将Crystal报表导出到记事本文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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