title: Export XLSX from custom python plugin for qgis
body: <p>With this code included in custom plugin for QGIS I write  on a csv file all the layer features and for each feature I do some actions.</p>
  <pre><code>        line1 = ';'.join(name for name in fieldnames)+';'+'note'+';'+'grandezze_misurate'+';'+'PIC_1'+';'+'PIC_2'+';'+'PIC_QR'+';'+'PIC_GE'+';'+'PIC_PLAN'+'\n'
          output_file.write(line1)
          
  
          # request = qgis.core.QgsFeatureRequest()
          # set order by field
           #clause = qgis.core.QgsFeatureRequest.OrderByClause(id, ascending=True)
           #orderby = qgis.core.QgsFeatureRequest.OrderBy([clause])
           #request.setOrderBy(orderby)
  
          # add some layer
         
          #features = selectedLayer.getFeatures(request)
       
          # wirte feature attributes
          #request = qgis.core.QgsFeatureRequest()
          #clause = qgis.core.QgsFeatureRequest.OrderByClause('id_mis', ascending=True)
          #orderby = qgis.core.QgsFeatureRequest.OrderBy([clause])
          #request.setOrderBy(orderby)
          for feat in selectedLayer.getFeatures():
            
              id = feat['id']
              x = str(feat['long'])
              y = str(feat['lat'])
              #print(id+&quot; &quot;+x+&quot; &quot;+ y)
              Path(QgsProject.instance().readPath(&quot;./&quot;)+'/'+selectedLayer.name()+'/IMMAGINI/').mkdir(parents=True, exist_ok=True)
              img = qrcode.make('https://www.google.com/maps?q='+y+','+x,box_size=2.9)
              img.save(QgsProject.instance().readPath(&quot;./&quot;)+'/'+selectedLayer.name()+'/IMMAGINI/'+id+'_QR.png')
              download_url='http://maps.googleapis.com/maps/api/staticmap?center='+y+','+x+'&amp;zoom=17&amp;size=640x301&amp;maptype=hyb&amp;sensor=false&amp;scale=1&amp;markers=color:red%7Clabel:%7C'+y+','+x+'&amp;key=AIzaSyCennHOjhBlpHeFPI-VbD24O8GEkXCXDbE'
              #print('http://maps.googleapis.com/maps/api/staticmap?center='+y+','+x+'&amp;zoom=17&amp;size=640x301&amp;maptype=sat&amp;sensor=false&amp;scale=1&amp;markers=color:red%7Clabel:%7C'+y+','+x+'&amp;key=AIzaSyCennHOjhBlpHeFPI-VbD24O8GEkXCXDbE')
              urllib.request.urlretrieve(download_url,QgsProject.instance().readPath(&quot;./&quot;)+'/'+selectedLayer.name()+'/IMMAGINI/'+id+'_GE.png')
              PATH =str(QgsProject.instance().readPath(&quot;./&quot;)+'/'+selectedLayer.name()+'/IMMAGINI/')
              a=PATH.replace(&quot;/&quot;,&quot;\\\\&quot;)
              line = ';'.join(str(feat[name]) for name in fieldnames) +';'+';'+';'+a+id+'_1.jpg'+';'+a+id+'_2.jpg'+';'+a+id+'_QR.png'+';'+a+id+'_GE.png'+';'+a+id+'_PLAN.jpg'+'\n'
              output_file.write(line)
  </code></pre>
  <p><strong>I need to write on a xlsx instead of a csv</strong></p>
  <p><strong>any suggestion?</strong></p>
  <p>thanks</p>