向大家问个统计的问题,我在内容里面写了例子,请大家帮忙回答

zhhhhao 2006-05-29 03:25:22
在水晶报表中现在有如下输入

id name num class
1 类别1 2 1
2 类别2 2 2
3 类别1 4 1
4 类别4 2 4
5 类别3 2 3
6 类别4 12 4
7 类别2 15 2
8 类别5 69 5



显示结果
类别1 num:6 6%
类别2 num:17 17%
类别3 num:2 2%
类别4 num:14 14%
类别5 num:69 69%

这个应该怎么搞呀,请教

...全文
117 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xwdd129 2006-05-31
  • 打赏
  • 举报
回复
排序要用到排序字段,右键-->报表-->排序记录,加好排序字段,可以有多个,以便在代码里控制!

水晶报表排序编程实例

Dim crReportDocument As ReportDocument

Public Sub changeSortField(mySortFld As String, mySortDir As String)

Dim crSortField As SortField
Dim crSortDirection As SortDirection
Dim crDatabaseFieldDefinition As DatabaseFieldDefinition

For Each crSortField In crReportDocument.DataDefinition.SortFields
If crSortField.Field.Name.ToString = mySortFld Then
crDatabaseFieldDefinition = crReportDocument.Database.Tables(0).Fields(mySortFld.ToString)
crSortField = crReportDocument.DataDefinition.SortFields(0)
crSortField.Field = crDatabaseFieldDefinition

If mySortDir = "Ascending" Then
crSortField.SortDirection = SortDirection.AscendingOrder
Else
crSortField.SortDirection = SortDirection.DescendingOrder
End If
End If
Next

CrystalReportViewer1.ReportSource = crReportDocument
End Sub
zhhhhao 2006-05-29
  • 打赏
  • 举报
回复
我搞定了其他,但是怎么按从少到多排序呀
zhhhhao 2006-05-29
  • 打赏
  • 举报
回复
百分比也能搞定吗
lbmshiwo 2006-05-29
  • 打赏
  • 举报
回复
好像是汇总哦
stone_soup 2006-05-29
  • 打赏
  • 举报
回复
通过Sql语句搞定!
到Sql版去看看.这个我不会.
zhhhhao 2006-05-29
  • 打赏
  • 举报
回复
d
zhhhhao 2006-05-29
  • 打赏
  • 举报
回复
d

4,819

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧