FAST REPORT 报表分组取消错误
笔者新近在开发一个由.NET 调用 FAST REPORT的程序时,预览报表时报出 “未能比较数组中的两个元素”,一直以为是数据源的问题,数据源是 由.NET的程序从SQL SERVER 读取数据表生成一个 DataTable ,再在FAST REPORT以在之前设计好的报表格式显示出来,其中用了一个唯一的GUID 字段进行分组。错误的界面如下:
文字如下:
System.InvalidOperationException: 未能比较数组中的两个元素。 ---> System.NullReferenceException: 未将对象引用设置到对象的实例。
在 FastReport.Code.AssemblyDescriptor.CalcExpression(String expr, Variant value)
在 FastReport.Report.CalcExpression(String expression, Variant value)
在 FastReport.Report.Calc(String expression, Variant value)
在 FastReport.Report.Calc(String expression)
在 FastReport.Data.DataSourceBase.RowComparer.Compare(Object x, Object y)
在 System.Array.SorterObjectArray.SwapIfGreaterWithItems(Int32 a, Int32 b)
--- 内部异常堆栈跟踪的结尾 ---
在 System.Array.SorterObjectArray.SwapIfGreaterWithItems(Int32 a, Int32 b)
在 System.Array.SorterObjectArray.QuickSort(Int32 left, Int32 right)
在 System.Array.Sort(Array keys, Array items, Int32 index, Int32 length, IComparer comparer)
在 System.Collections.ArrayList.Sort(Int32 index, Int32 count, IComparer comparer)
在 FastReport.Data.DataSourceBase.Init(Relation relation, String filter, SortCollection sort, Boolean useAllParentRows)
在 FastReport.Data.DataSourceBase.Init(DataSourceBase parentData, String filter, SortCollection sort, Boolean useAllParentRows)
在 FastReport.DataBand.InitDataSource()
在 FastReport.GroupHeaderBand.InitDataSource()
在 FastReport.Engine.ReportEngine.RunGroup(GroupHeaderBand groupBand)
在 FastReport.Engine.ReportEngine.RunBands(BandCollection bands)
在 FastReport.Engine.ReportEngine.RunReportPage(ReportPage page)
在 FastReport.Engine.ReportEngine.RunReportPages()
在 FastReport.Engine.ReportEngine.RunReportPages(ReportPage page)
在 FastReport.Engine.ReportEngine.Run(Boolean runDialogs, Boolean append, ReportPage page)
在 FastReport.Engine.ReportEngine.Run(Boolean runDialogs, Boolean append)
在 FastReport.Report.Prepare(Boolean append)
在 FastReport.Report.Prepare()
在 FastReport.Design.ReportTab.Preview()
内部返回的错误我们没有办法跟踪和调试,后来换了 多个数据源 都是这样的错误,再经过重新建报表还是同样的问题。最后我转变思路应该是本身报表的结构问题,最后在报表的分组里面不小心把分组的字段删除掉了,截图如下: