4

I have difficulty in how to rotating attribute table in QGIS Composer. The default is horizontal, it's because data I have too much around 50 tables. So I want to rotated it to horizontal.

Under the map, or maybe there is another way for me to include this all record and print it out?

enter image description here

3 Answers 3

8

There is no direct way to rotate/transpose your attribute table in the map composer as far as I know. A workaround to this is:

  1. Right-click the file and go to Save as then save your attribute table as CSV. If you don't want to add XY coordinates as additional columns to the CSV file, select Default in GEOMETRY under Layer options.

enter image description here

enter image description here

  1. Open the CSV file in Excel
  2. Then copy the columns
  3. Paste them on another sheet using paste special, and select Transpose
  4. Save it again as a CSV file

Then drag and drop the new CSV file into QGIS. In the composer add the transposed attribute at the bottom of your map.

enter image description here

2
  • Sorry I dont know how to save attribute table as CSV ???? i am very new with this, please and thank you Commented Feb 6, 2017 at 4:17
  • I updated I my answer to show you how to save the file as CSV.
    – ahmadhanb
    Commented Feb 6, 2017 at 4:58
3

@ahmadhanb's answer is a good workaround but here is another way to deal with long tables.

Although there is no way to transpose a table in the composer, you can split your table into multiple frames. Now depending on the case, this could be more or less elegant, but this is how the result looks like:

Split table

Here's how to do it:

  1. Add a table as you would normally do and select its source layer.
  2. Scroll down the properties till you get to Frames. table properties
  3. Click Add Frame.
  4. Align and resize your frames as may be suitable to your map layout.
  5. It is also a good idea to turn on Show only features visible within a map. This way you won't have a table with all the layer features on your map!

show visible

P.S. It is possible to rotate the table, but unfortunately, the text also rotates and you end up with vertical text, which doesn't look very elegant. enter image description here

1

Here is a solution to get a transposed attribute table for one feature at a time in an Atlas. This solution works if creating one map for each feature is acceptable.

First set up you an atlas: Atlas settings - choose your layer as the coverage layer (the atlas will create a map for every feature and zoom on that feature, the next steps explain how to show the attributes of the zoomed-in feature, in column format, on each map).

Before adding a Fixed Table to you map Layout, you might want go to a spreadsheet editor (LibreOffice Calc or Excel): paste your attribute table in transpose (right-click - paste special - transpose) - you only need the column names (transposed to rows). Add a second column with this formula (assuming first element is in cell A1): =CONCAT("attribute('";H14;"')") Copy the two columns:

1_Spreadsheet

Back to the map Layout, add a Fixed Table, then paste you data (File - Import content from clipboard). (I modified the X and Y attribute names to show the point coordinates.):

2_Paste the two columns to a Fixed Table

For some reason, the second row is not recognized as an expression; for each row, you will have to manually copy-paste the cell content to the Expression box to the right. Once done for every row, you can close the table:

3_Manually fix the second row so it is recognized as an Expression

To see the result don't forget to go click on Atlas Preview! (remember, this is an atlas) I added a second map with an overview:

4_Map with transposed attribute table

Protip for the Overview: item properties - overviews - Frame style - change to OutlineSimpleLine and use a negative offset to make the overview square a bit larger and more visible on your map):

4.2_Overview outline negative offset

1
  • Instead of writing Attribute('TreeShade') one can just write "Treeshade"
    – Morten
    Commented Aug 14, 2023 at 6:51

Your Answer

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

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