48

I have seen all the questions for how to export an attribute table to Excel from QGIS, and I try all the answers like copy paste, CSV (in fact this I do not know where to find), but none seems to be the right answer.

Can anyone help me?

Taras
  • 32,823
  • 4
  • 66
  • 137
Po Po
  • 841
  • 1
  • 8
  • 14
  • 1
    What method have you tried for copy-paste into Excel? – Simbamangu Feb 18 '15 at 14:13
  • 1
    Siple copy-paste. Select all the feature, copy, open excel, select more then my feature cloumns, rows and paste. Am I right? – Po Po Feb 18 '15 at 15:07
  • 1
    Yes, select-all then copy, but don't try to select the range of cells within Excel, paste into a single cell. What error did you get? – Simbamangu Feb 18 '15 at 19:25
  • 1
    Many rows with a long number. In some cells the information is missing. Looks like it is not the right way? Shuold have another way that give you the column and the rows like they are in your attribute table. – Po Po Feb 18 '15 at 20:33

8 Answers8

77

QGIS v3.x

Right click on the layer in the Table of Contents (aka. legend or layer tree) and open the Save As... dialog.

Once there, click on the Format option list and choose MS Office Open XML spreadsheet [XLSX].

Note that you also have an option for Libre Office files: Open Document spreadsheet [ODS].


ORIGINAL ANSWER (no longer valid):

  1. Install the XY Tools plugin by Richard Duivenvoorde.

  2. Select a vector file from the ToC (that is, make it active).

  3. Go to Vector->XY tools->Save attribute table as Excel file.

enter image description here

You would need the Python library xlw installed for doing so.

Germán Carrillo
  • 36,307
  • 5
  • 123
  • 178
  • Yes, but I want it for free. To get XYtools you need to pay. Is there any other way? – Po Po Feb 18 '15 at 14:22
  • 2
    @PoPo You don't need to pay for using XY tools plugin, I myself use it. The author suggests you to donate 5€ if you use the plugin, but it's up to you to donate. – Germán Carrillo Feb 18 '15 at 14:23
  • Can you give me a link, please? – Po Po Feb 18 '15 at 14:25
  • 1
    @PoPo You can download the plugin from here or simply go to Plugins->Manage and Install plugins and search for xytools. – Germán Carrillo Feb 18 '15 at 14:27
  • Yes now I have that,but look the problem that it have An error has occured while executing Python code:

    Traceback (most recent call last): File "C:.qgis2/python/plugins\xytools\xytools.py", line 301, in excelSave xlw.writeAttributeRow(rowNr, values) File "C:.qgis2/python/plugins\xytools\providers\excel.py", line 51, in writeAttributeRow cell = str(cell) UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-4: ordinal not in range(128) Python version: 2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] QGIS version: 2.2.0-Valmiera Valmiera, c3a2817

    – Po Po Feb 18 '15 at 14:36
  • @PoPo Can you try the previous version of the plugin? You can download it from here. – Germán Carrillo Feb 18 '15 at 14:46
  • It not allow me to choose the previous version, but download the lastes verison. – Po Po Feb 18 '15 at 15:30
  • Might be this issue with non-ASCII-caharcters as field values: https://github.com/rduivenvoorde/xytools/issues/3 – AndreJ Feb 18 '15 at 15:52
  • 1
    @PoPo You can download it from the last link I gave you, delete your current xytools folder in USER/.qgis2/python/plugins/. Then extract the downloaded zip into that location. Restart QGIS and you're done. I see there were modifications to the file excel.py in the latest version, and I've used the previous one without problems. – Germán Carrillo Feb 18 '15 at 16:09
  • 1
    @gcarrillo Thank you. Yes, now it's working. Thank you a lot. – Po Po Feb 18 '15 at 20:43
  • When I installed the XY Tools I found that some python library was missing from my install (osx). Not sure what it was. I voted for the CSV answer by AndreJ because ultimately that's what I wanted -- this question came up when I searched for "qgis export attribute csv". Also, because CSV is more useful than an "Excel file" because it is natively supported by any reputable spreadsheet program, including basic text editors. – aaryno Jun 02 '16 at 00:07
  • It's up to you. I still read in the title "How to export attribute table to Excel from QGIS?". – Germán Carrillo Jun 02 '16 at 01:35
  • 1
    This answer is a little outdated, I found the answer below to be more current. – edge-case Nov 08 '19 at 16:21
29

To get a csv file of the attribute table, rightclick on the layer in the legend, select Save As ..., and change the file format from shapefile to CSV.

You might need to change the separator from comma to semicolon in a text editor if Excel does not like the default separator.

AndreJ
  • 76,698
  • 5
  • 86
  • 162
  • Yes I try to do that but I din't find csv format file in my drop-down menu. Can you show an image, please. – Po Po Feb 18 '15 at 14:24
  • 1
    "Comma Separated Value [CSV]" third option from the top. – HeikkiVesanto Feb 18 '15 at 14:47
  • Thanks, but now it's not working. I cann't open the file in Excel. – Po Po Feb 18 '15 at 15:59
  • 1
    This answer is more robust, because it works for other generic spreadsheet programs as well. CSV is easily opened in Excel through the Import Text wizard. You just need to specify "Text (CSV)" in the format – aaryno Jun 02 '16 at 00:04
14

In QGIS versions 3 and above, the easiest way to export an attribute table is to:

  1. Right-click the attribute layer in the layers menu
  2. Select Export and Save features as...
  3. At the top of the program window, select Comma Separated Value [CSV] in the format drop-down menu
  4. Type a file name for the file to be saved
  5. Click the three-dot button ... next to the file name to choose a path to where the file should be saved
  6. Uncheck any fields you do not want in your resulting file
  7. Optionally (probably) uncheck the add saved file to map at the bottom of the window so that the file does not get added to your project as a data layer
  8. Click the green check mark, Ok button
Taras
  • 32,823
  • 4
  • 66
  • 137
CW Dillon
  • 141
  • 1
  • 3
  • This is the most recent and accurate answer for the more recent versions of QGIS. I'm using 3.4.11-Madeira and this worked for me. – edge-case Nov 08 '19 at 16:18
12

There's also the MMQGIS Plugin which, when downloaded and installed from the toolbar (Plugins > Manage and Install Plugins...), has the tool:

MMQGIS > Import/Export > Attributes Export to CSV File

MMQGIS Attributes Export to CSV File

Taras
  • 32,823
  • 4
  • 66
  • 137
Joseph
  • 75,746
  • 7
  • 171
  • 282
4
  1. Select rows
  2. Copy selected rows to clipboard
  3. Paste in Excel

enter image description here

BERA
  • 72,339
  • 13
  • 72
  • 161
  • 4
    This is my preferred method. I found it a bit annoying that the geometry field was copied as well until I discovered one can go to Settings - Data sources and change the Copy features dropdown to plain text, no geometry. I also find the fields & rows can be oddly sized for word wrapping in Excel, but if I expand the column width to some overly large size, I can then use the autofit fields and rows options in Excel to get a nice looking table. – John Feb 03 '21 at 14:32
  • Most helpful. Here is what worked after many failures with a notice no copy was made. As johns suggested, I went to Settings - Data sources, and changed to plain text, no geometry. Then, instead of using Control+A to select the 16 features I had filtered to using an expression to filter out from about 20,000 features to the 16 I needed, I selected each row one at a time holding down the Control key (when I used Control + A to select all of the 16 features showing, I believe it tried to copy all 20,000+ features in the layer (not visible to me), which also happened with the export method). – JJD Jul 30 '21 at 01:57
  • Keep in mind : this approach will also copy the hidden column "wkt_geom" with geometry! – Taras Mar 14 '22 at 07:34
4

From QGIS 3.18 (see the Changelog), you can use the "Export to spreadsheet" algorithm available in the QGIS's Processing Toolbox (Ctrl+Alt+T).

It enables to export one or more layers in multiple sheets, to overwrite or append them to existing files. Output formats supported are Excel XLSX and Open Document Spreadsheet ('.ods')

Fine for exporting full layers, otherwise, keep using already mentioned methods in other answers when you need to export selected features to spreadsheet

Export to spreadsheet screen capture

Taras
  • 32,823
  • 4
  • 66
  • 137
ThomasG77
  • 30,725
  • 1
  • 53
  • 93
2

Export the layer as a shapefile, find the shapefile on your PC. Copy/Rename the filename of the DBF part of the shapefile exportes to be 8 or under characters if it's not. (OLD MS DOS FILENAME ISSUE). Then, drag-drop the DBF right into Excel.

Save as XLS.

The copy paste method right form QGIS made text/character returns in a blob reset to the next row and cause data problems in excel.

northtron
  • 29
  • 1
1

X/Y tools is regrettably no longer available in QGIS 3.x. There is another way how to export the attribute table to Excel, without any trouble concerning text encoding, column names and fields containing special characters in foreign languages like e.g. Vietnamese,. However, your input file should be in UTF-8 encoded:

  1. Right click on the shp file, Export, save features as Open Document Spreadsheet (ODS.
  2. Open the ODS file with LibreOffice or MS Excel.
  3. Save as Excel file (xls or xlsx)
HaraldVTN
  • 11
  • 2