my program creates a bunch of word files :they contain informations about students such as Name address Phone number ... and a barcode . When I insert my QRCode as a picture , it is appended at the end of the file . I want it to be inserted at the very right of the text "Barcode" . I looked for a solution in vain . I inserted a picture of the word explain . Sorry I've hidden the informations because it is confidential. Here is my Code :
import uuid
import pandas as pd
import pyqrcode
from docx import Document
from docx.shared import Inches
def generateBarCode(length):
return str(uuid.uuid4()).replace('-','')[0:length]
df=pd.DataFrame(pd.read_excel('Komplette-
GastAccountFHZugangsdatenFertig.xlsx'))
array=[]
for i in range(len(df)):
qr=pyqrcode.create(generateBarCode(8))
array.append(qr)
df.insert(8,'Barcode',array)
x=['.png']
with pd.ExcelWriter('Komplette-GastAccountFHZugangsdatenFertig.xlsx') as
writer :
df.to_excel(writer,sheet_name='Sheet1')
for i in range(len(df)):
document=Document()
document.add_heading('Informationen')
document.add_paragraph('Name : ' + df['Name'][i])
document.add_paragraph('Vorname : ' + df['Vorname '][i])
document.add_paragraph('Geschlecht : ' + df['Geschlecht'][i])
document.add_paragraph('Adresse(in Marokko) : ' + df['Adresse (in
Marokko)'][i])
document.add_paragraph('Telefonnummer : ' + str(df['Telefonnummer'][i]))
document.add_paragraph('E-Mailadresse : ' + str(df['E-Mailadresse'][i]))
document.add_paragraph('Studiengang : ' + df['Studiengang'][i] )
document.add_paragraph('Semester : ' + str(df['Semester'][i]))
document.add_paragraph('Barcode : ')
qr=df['Barcode'][i]
qr.png(df['Name'][i]+df['Vorname '][i]+x[0])
document.add_picture(df['Name'][i]+df['Vorname ']
[i]+'.png',width=Inches(2.0))
document.save(df['Name'][i]+' '+ df['Vorname '][i]+'.docx')
Screenshot
Thanks