Click here to Skip to main content
16,016,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 ?

C#
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.
Posted
Updated 19-Aug-16 1:07am
v2

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.
 
Share this answer
 
Comments
Member 12258996 19-Aug-16 7:04am    
It Creates a Notepad File But the data in file is not Understandable to me. PLZ HELP ANY ONE.
Member 12258996 19-Aug-16 7:05am    
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.
C#
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");






C#
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900