报表动态列怎么做比较好

使用jasperreport+ireport
比如A表
id 部门名 员工类型 员工数
1 D1 E1 2
2 D1 E2 1
3 D2 E1 3
4 D2 E2 0
... .. .. ..

要求得到如下的报表

D1   D2  ..

E1 2 3 ..
E2 1 0 ..
.. .. .. ..
8)怎么做比较好?

[code="sql"]select 员工类型 as '员工类型' ,
sum(case when 部门名 = 'D1' then 员工数 else 0 end ) as D1,
sum(case when 部门名 = 'D2' then 员工数 else 0 end ) as D2,

sum(员工数) '员工数' from A
group by 员工类型[/code]
这条语句可以实现您那样的格式,但有多个部门的情况要你动态区判断区拼sql语句了我只是给您提供一下思路和sql语句的写法。

没用过jasperreport+ireport
但是觉得,可以写查询语句来得到这样的结果集啊,然后在jasperreport+ireport 里面设置下吧

以前做过,jasperreport支持写sql的啊!
先写好sql,把返回的记录集写成你需要的格式就可以了。

朋友,问题要自动关闭啦,结分哦,

朋友,问题要自动关闭啦,不结分你会被扣20哦 ~

[url=http://blog.gcpowertools.com.cn/post/ActiveReports_Dynamics_PageReport.aspx]http://blog.gcpowertools.com.cn/post/ActiveReports_Dynamics_PageReport.aspx[/url]
这篇博客讲的很清楚