数据设置为C#中的水晶报表 [英] Data set to crystal report in C#

查看:109
本文介绍了数据设置为C#中的水晶报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Arraylist转换为数据集,然后将数据集设置为Crystal报表
.在数据集中,我有总计"字段作为额外的列,该字段将在程序执行期间进行计算,但不在数据库中.如何在水晶报表中显示总列...请帮助我...谢谢您的宝贵时间....

How to convert Arraylist to dataset and then set the dataset to the crystal report
. In data set i have "Total" field as extra column which will be calculated during the program execution time,also which is not in the database . How to show the total column in the crystal report...Please help me...Thank you for your precious time....

推荐答案

听起来像您需要做一些研究.这是指向您正在使用的对象的MSDN链接:
数据集 [数据表 [ ArrayList [
It sounds like you need to do some research. Here are the MSDN links to the objects you are working with:
DataSet[^]
DataTable[^]
ArrayList[^]

First of all, a DataSet is a collection of DataTables. When you say you have a column in your DataSet, you probably really mean that you have a DataTable in your DataSet and that DataTable has the columns.

Now, in order to "convert" the data from your ArrayList you will have to loop through the ArrayList and add each item into the DataTable that is contained in your DataSet. You can create the loop using a For Each statement. Here is a sample (It''s in VB.Net, but you should be able to get the idea and convert to C# pretty easily):
Dim myDataSet As New DataSet
Dim myDataTable As New DataTable
myDataTable.Columns.Add("Column1")
myDataSet.Tables.Add(myDataTable)

Dim myArrayList As New ArrayList

'Code that puts data into your array list would go here

'Here is the For Each loop.  It will loop through each object in the ArrayList
For Each obj As Object In myArrayList
    Dim rowNew As DataRow = myDataTable.NewRow 'Creates a new row that has the same schema as the myDataTable object
    rowNew("Column1") = obj.ToString 'Takes the object in the array list and puts it in a new row
    myDataTable.Rows.Add(rowNew) 'Adds the new row to myDataTable
Next


如果您的数据表中还有其他列,那么您也必须填写这些列.另外,根据列的数据类型以及要用ArrayList填充的数据,可能必须将ArrayList中的对象转换为正确的数据类型.

为了使总数显示在水晶报表中,您将必须编辑报表文件本身以包括新字段.如果需要组总计,则可能必须设置组,或者可能必须设置页面或报告页脚.您可能想通过Google或通过Code Project上的文章进行一些研究,以研究如何做到这一点.

希望这会有所帮助.


If you have other columns in your DataTable, you''ll have to fill those as well. Also, depending upon the data type of your columns and what data you are filling your ArrayList with you may have to convert the objects in your ArrayList into the proper data type.

As for getting the total to appear in your crystal report, you will have to edit the report file itself to include your new field. You may have to setup groups if you want group totals or you may have to setup a page or report footer. You''ll want to do some research either by google or through articles here on Code Project to research how to do that.

Hope this helps.


这篇关于数据设置为C#中的水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆