Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 views
in Technique[技术] by (71.8m points)

sql server 2008 - SSRS report formatting a table to display data side by side

I am trying to achieve the following layout for my report based on one query.

+----+-------+----+-------+
| ID | Name  | ID | Name  |
+----+-------+----+-------+
|  1 | Danny |  2 | Dave  |
|  3 | Sue   |  4 | Jack  |
|  5 | Rita  |  6 | Sarah |
+----+-------+----+-------+

So I basically want one table, printing my data from left to right to save space on my page, rather than it printing one line and wasting all of the space on the right side of the paper, possibly even go 3 times across the width.

This is my data: http://sqlfiddle.com/#!3/5c911/1

I was maybe thinking a table with 4 columns. Cols 1 and 2 contain the odd row numbers, Cols 3 and 4 contain the even row numbers.

How could I achieve this, I did try something with the MOD function but it didn't seem to work properly, or I misunderstood what was happening.

Related: How can I display two rows worth of data on one line side-by-side in Report Designer?

Thanks,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To print your data from left to right in a multi-column format, you need to fake it using multiple tables. To implement this hack, create the same number of tables as columns you want side by side that all point to your data set. On the Detail row of the first table, for the Visibility-Hidden property use the following formula:

=IIF((RowNumber(Nothing) Mod 4) = 1, False, True)

where 4 is the number of tables (columns) you have.

Do the same for each table, incrementing what the formula is equal to (so for the second column (RowNumber(Nothing) Mod 4) = 2 and so forth). In the last table (column) the formula equals 0.

This alternately hides the detail row, only displaying the appropriate rows for that column number.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...