6

I'm using QGIS 2.18.3 (Las Palmas).

I added the attribute Table in my print composer and would like to display it in 2 column (I have around 50 Cities I would like to display. Instead of having one long column that would need 2 pages, I would prefer splitting the attribute table in 2 columns).

It has worked before, but it was more by luck: for some reason my print composer automatically assumed I would need two pages, when I set the page-Number back to one, my attribute Table was split.

However, this is not working at the moment, and I would like to know if there is a better way of achieving what I need.

Is there a better way of working with attribute Tables in Print composers?

2 Answers 2

9

It's over a year since this question was asked, but as I had a similar problem, I would like to mention that in QGIS 3.4 you can now solve this problem by setting the resize mode for attribute tables in Print Layouts to 'Use existing frames' and add as many frames as you want - wherever you want, whatever size - to spill over from the first frame and optionally repeat headers.

You can set it up so empty frames don't display or show another message.

enter image description here

enter image description here

1
  • Many Months have passed, but your solution helped me today!
    – rtaani
    Jan 17, 2020 at 16:14
8

You can achieve what you want by saving your table in CSV format. If your city data is in shapefile format, you can export it to CSV by right-click the city layer in the table of content -> Save as -> Select CSV under format, and choose Default under Geometry tab if you don't want to the X and Y coordinates of the City point data, as you can see below:

enter image description here

The next step is to give the City data an ID for each row. You can do this in QGIS by adding a column with name ID update the ID field using the expression $id, or you can open the CSV file in Excel and add a column ID and fill it with a sequence number (1 -50), and save the CSV.

In QGIS, drag and drop the CSV table into the QGIS project, and in the print composer click on Add attribute table:

enter image description here

Here is the real work. You can control the number of rows to show under Maximum rows and you can put 25, but in this example I put 40, and check Filter with to show only the first 25 rows in your CSV using the expression:

"ID" >= 1 AND "ID" < 26

enter image description here,

You can also control the font size and type and do whatever you want. The attribute property has a long list of options to control the appearance of your table.

Now, repeat the previous step by clicking on Add attribute table, using Maximum rows with 25 rows and Filter with to show the next 25 rows in your CSV using the expression:

"ID" >= 26 AND "ID" < 51 

Here is the output (But I am using different row numbers):

enter image description here

If you don't wont to show the ID column in the layout, you can click on Attributes -> Select ID row -> Red Minus to remove the ID from the attribute table. It will not affect expression in the Filter with

enter image description here

Here is the output without ID columns:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.