开发者

Dynamically generating all dates in a month in Crystal Reports

I'd like to display dynamic columns at run time for开发者_JS百科 each day in a given month.

Example: If January then 31 columns will be displayed. If February then 28 columns will be displayed. If March then 31 columns will be displayed. If April then 30 columns will be displayed. And so on.

How can I do this?


You have two challenges: creating the data and 'pivoting' it.

Most data warehouses contain a date-dimension table that you could query to get all of the dates for a given month and year. If you want something more dynamic, you might be able to adapt my DateRanges() function for this purpose.

The next challenge it to convert the rows to columns. Crystal Reports' cross-tab does this with ease, at the expense of some flexibility. I usually make use of the summarized-field's Display String formula to do fancy formatting.

You could also create 62 formula fields (31 for the labels and 31 for the data), place them on the canvas, and suppress the 29th - 31st fields as appropriate.

If this report is being generated by custom code (as opposed to being deployed in BusinessObjects Enterprise), you could use the Crystal Reports SDK to dynamically create the columns that you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜