简体   繁体   English

如何使用类中的数据制作Crystal报表?

[英]How to make a Crystal report with data from classes?

I am new to this tool, so I do not know how I can get the data of a class and show in a report. 我是这个工具的新手,所以我不知道如何获取类的数据并在报告中显示。

I don't have a database, my info is stored inside variables inside classes. 我没有数据库,我的信息存储在类内的变量中。 Like this (Folder Objetos): 像这样(Folder Objetos): 顶级的是NFe

My program does: Read a XML, validate with XSD, serialize in this classes. 我的程序可以:读取XML,使用XSD进行验证,在此类中进行序列化。 What I want: Take that information and show in a report. 我想要的:获取这些信息并在报告中显示。

It is possible to put my data from variables in a Crystal report? 可以将变量中的数据放在Crystal报表中吗? Where I start? 我从哪里开始?

well crystal report can take many things as " DataSource" ranging from object, datatable, dataset etc etc. without looking at the code it is hard to figure out where you are having issue. 井水晶报告可以采取很多东西作为“数据源”,范围从对象,数据,数据集等,而不看代码,很难找出你有问题的地方。

basic syntax for crystalreport load datasource is crystalreport load datasource的基本语法是

CrystalDecisions.CrystalReports.Engine.ReportDocument reportDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        reportDoc.Load("your RPT file");

reportDoc.SetDataSource(object)

here instead of object you can use dataset, datatable etc.\\ 这里代替对象你可以使用数据集,数据表等。

Is this what you were looking for ? 这是你在找什么?

Added 添加

reportDoc.SetDataSource(ds.Tables["YourTableName"])

Also one more thing to note is if you report requires lets say 20 fields they all must be preset in the datatable. 还有一点要注意的是,如果您报告要求允许说20个字段,则它们都必须预设在数据表中。 or else it will not work. 否则它将无法工作。 if it has any extra fields in dataset it will just ignore those 如果它在数据集中有任何额外的字段,它将忽略这些

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM