我正在尝试使用 C#.Net 导出水晶报表,但不幸的是我遇到了错误,因为我在每页指定了几行。尽管我已经指定了大量的行。你能帮我解决这个问题吗?请参阅下面我的代码以供参考。
谢谢你。
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();
}
}
在我看来,ExportToDisk 选项会自动覆盖linesPerPage。尝试执行 Report.Export,这应该可行。
尝试这样的事情:
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);