I have created some code to select a specific layer in the Layers Panel. Now I want to export the selected features to an Excel document. Is there a way to do this?
Code so far:
#Select layer to export selected features
name = 'Individual Trees'
view = iface.layerTreeView()
m = view.model()
listIndexes = m.match(m.index(0, 0), Qt.DisplayRole, name, Qt.MatchFixedString)
if listIndexes:
i = listIndexes[0]
view.selectionModel().setCurrentIndex(i, QItemSelectionModel.ClearAndSelect)
#Export to excel file: C:\\Users\\MatthewWhitehead\\OneDrive - Innovative Forestry Ltd\\Arboricultural Reports\\Tree Condition Survey\\Tree_Condition_Ind_Export.xlsx