作者fumizuki (蒙面加菲狮)
看板Visual_Basic
标题CrystalDecisions.CrystalReports.Engine: IndexOutRangeException
时间Fri Apr 13 16:13:57 2007
CrystalDecisions.CrystalReports.Engine: IndexOutRangeException
作业环境:
Windows Server 2003 Enterprise
Visual Basic .NET 2003
Crystal Report 10 For .NET 2003
程式码片段:
oRpt.PrintOptions.PaperSize = PaperSize.PaperA4
oRpt.PrintOptions.PaperSource = PaperSource.Auto
oRpt.PrintToPrinter(1, False, 0, 0)
以上,第三行程式码会产生一个 System.IndexOutOfRangeException 的错误
我有设中断点查看错误,以下是 Exception 提供的资讯
ex.Source = CrystalDecision.CrystalReport.Engine
ex.Message = "索引在阵列的界限之外。"
ex.StackTrace =
at CrystalDecisions.CrystalReports.Engine.Migration.PrintOptionsConverter.EROMPaperSourceToDNETPaperSource(CrPaperSourceEnum ePaperSource)
at CrystalDecisions.CrystalReports.Engine.PrintOptions.get_PaperSource()
at CrystalDecisions.CrystalReports.Engine.PrintOptions.CopyTo(PrinterSettings printer, PageSettings page)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
at Shinher.fReport.ShowReport(Boolean PrintNow) in fReport.vb:line 1238
ex.InnerException = Nothing
我亦在监看式中加入 oRpt.PrintOptions
PaperSource 那个成员亦出现了相同的错误:
<error: an exception of type: {System.IndexOutOfRangeException} occurred>
程式中加入 PaperSize 及 PaperSource 那两行设定,照样出现这个错误。
奇怪的是在别的程式中,同样的方法,根本也不用设定 Paper,并没有这个问题,
在这支程式中会发生这个错误,每一张报表都一样,
只要执行到 PrintToPrinter 这行就发生错误,
如果使用 CrystalReportViewer 先预览,再点画面中的列印按钮,可以正常列印。
我还异想天开的改成 oRpt.PrintToPrinter(1, False, 1, 1),也没有用
预览画面就可以确定报表档案本身并没有问题,资料来源也是可以正确秀在报表上的
真的就不知道这到底是什麽问题了,
请问是 CrystalReport 的 bug 吗?还是其它问题?该如何解决呢?
--
▃▅▇▆▄ ▆▂▃ `
逝去感情如何能留住,半点痴情遗留殊不易,██▅▇▄▃ ▇▃▂" .
█████████▃i ▁▄▇
更多凄凄惨惨的遭遇…………██▆▃ █▅▆▃ˍ▄*
◢ ▂█▄▇▅▂▌.
我不知道,王~八~蛋~~! ▂▆███ █▄▃ 。fumizuki。Check。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 60.248.175.60
1F:推 colawei:也许试着换一下预设印表机或指定印表机看看... 04/13 20:46
2F:推 fumizuki:能提供指定印表机的程式码参考吗(我本身是有试过 没成功) 04/14 06:22
3F:→ colawei:我现在是用CRXI+VB2005,没那种问题所以帮不上忙.sorry. 04/19 19:50