I am using windows form to generate Identity Card using c# and Microsoft report viewer. Everything is working fine except I could not find column repeat direction in Microsoft report viewer.
Current Scenario
My report paper size is A4. Each page can display maximum 10 individual cards. There are 2 columns in page. Each column display 5 cards. It is generating card as shown in image. The column repeat direction is vertically. It first list 1st column (1-5) and then list 2nd column (6-10).
My Requirement
I want the report column repeat direction to be horizontally like in the image below. First display 1 then 2 and 3 and 4 and so on.
Why I want to display horizontally rather than vertically?
It will save the paper. For example, if the user generate 4 Identity cards only then as per current scenario, it will generate 4 cards in column 1 and the whole page space is wasted because I can not re-use the left space.
By repeating the column direction to horizontally, the 4 cards will be displayed as in column 1, card 1 and 3 and in column 2, card 2 and 4 will be displayed. I can then cut the paper and reuse it later.
I have searched alot but could not find any solution. Any suggestion, comments or links will be helpful. I can not use any other reports. Thanks in advance.
The column group hierarchy expands vertically. These cells are added automatically when you create a group, and display the unique values for a group at run time. Cells in the tablix corner are created when there are both row and column group areas.
In SSRS RDL standard, “tablix” is a generalized term that means the combination of table, matrix (cross-table or pivot table), and list report items (table+list+matrix=tablix). It displays report data from a data set in cells that are organized into rows and columns.
If you want to change column width dynamically, you could try the workaround in this article: SSRS Column Width Auto Size. But your requirement that make the column width reference to a field value returned in dataset cannot be achieved right now. If you still have any question, please feel free to ask.
Holding the left mouse button down, drag vertically or horizontally to select adjacent cells. The selected cells are highlighted. Right-click the selected cells and select Merge Cells. The selected cells are combined into a single cell.
Create a matrix
Define your row grouping as
=Ceiling(Fields!CardNo.Value/2)
Define your column grouping as
=Fields!CardNo.Value Mod 2
Your report design will look something like this. Outer group is just shown for illustration purposes but you can delete it.
Now when you run the report. You will get the result you are looking for
Without any grouping header and footer. Your report output will be
This problem can be seen as mapping problem where you need to reshuffle your items as follow:
n -> f(n)
----------
1 -> 1
2 -> 6
3 -> 2
4 -> 7
5 -> 3
6 -> 8
7 -> 4
8 -> 9
9 -> 5
10 -> 10
n is the original position
f(n) is the mapped position
It can be seen that it follows a pattern like this:
f(n) = floor(n / 2) + 1
if n is oddf(n) = (10 + n) / 2
if n is evenThus, you may want to reshuffle the order you put your items in that following manner. That is given index
of the item from 0-9 (start from 0 is following C# typical number indexer), you could do something like this:
index++;
int newIndex = index % 2 == 0 ? (10 + index) / 2 : index / 2 + 1;
newIndex--;
And you should be able to place your Cards
correctly.
Note: without actually code given, this is to show how you can solve the problem conceptually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With