Write in pre-written xlsx format template in python
<p>I am a bit new in python now working in qgis to automates some time. 
I have an excel pre-written template file where i have to add different data in different columns.</p>

<pre><code>outpufFile = open('d:/template.xlsx','w')
for layer in QgsMapLayerRegistry.instance().mapLayers().values():
    print layer.name() +","+ str(layer.featureCount())
    line = layer.name()
    unicode_line = line.encode('utf-8')
    outpufFile.write(unicode_line)
outpufFile.close() 
</code></pre>

<p>I get this so far but it corrupting my template while I also don't know how to access specific column or row of my file In order  to write at exactly column and row to full my template.</p>

<p>You need a Python library that understands how to handle xlsx files: </p>

<p><a href="https://openpyxl.readthedocs.io/en/default/" rel="nofollow">openpyxl</a>, for example.</p>

python excel