Reputation: 23
I am trying to Export A Crystal Report using C#.Net, but unfortunately I'm having and Error that I specified few lines per page. Even though I already specified a large amount of lines. Can You help me regarding this? Please see my code below for reference.
Thank you.
void XportZ()
{
try
{
cryRpt.Load(@"D:\Arnie Files\Projects\BIR E-journal\ZTapeReport_PwdAdj_v2.1.rpt");
cryRpt.DataSourceConnections[0].SetConnection("FA17083", "MyDB", "sa", "qwerty");
cryRpt.SetParameterValue(0, dt_BusinessDate.Value.ToString("MM/dd/yyyy"));
cryRpt.SetParameterValue(1, "☺" + txt_PosID.Text + "☺");
ExportOptions.CreateTextFormatOptions().CharactersPerInch = 60;
ExportOptions.CreateTextFormatOptions().LinesPerPage = 100;
cryRpt.ExportToDisk(ExportFormatType.Text, @"D:\_AAAAAA\Zreading" + txt_PosID.Text + dt_BusinessDate.Value.ToString("MMddyyyy") + ".txt");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
hasError = true;
}
finally
{
cryRpt.Dispose();
cryRpt.Close();
}
}
Upvotes: 0
Views: 1053
Reputation: 5670
Try something like this:
ExportOptions exportOpts = new ExportOptions();
DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions();
diskOpts.DiskFileName = @"D:\_AAAAAA\Zreading.txt";
exportOpts.ExportFormatType = ExportFormatType.Text;
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
exportOpts.ExportDestinationOptions = diskOpts;
TextFormatOptions textFormatOptions = ExportOptions.CreateTextFormatOptions();
textFormatOptions.CharactersPerInch = 10;
textFormatOptions.LinesPerPage = 0;
exportOpts.ExportFormatOptions = textFormatOptions;
document.Export(exportOpts);
Upvotes: 0
Reputation: 31
It seems to me the ExportToDisk option automatically overrides the linesPerPage. Try doing Report.Export and that should work.
Upvotes: 0