简体   繁体   中英

writing data including image into an xlsx or xls file using python

i really need you help in this i am working on attendance system using rfid, every time student scan their cards take data from card uid and saved into xlsx file also at the same time take a photo of the student and saved into the same file, my problem is every time i scan the card, the data overwrite on the previous one

workbook = xlsxwriter.Workbook('/home/pi/Desktop/k.xlsx')
            worksheet = workbook.add_worksheet()
            r = 1
            m = str(r)
            worksheet.set_column('B:B', 10)
            worksheet.set_column('A:A', 15)
            worksheet.write('A'+m,row[0] )
            worksheet.write('B'+m,row[2] )
            worksheet.write('C'+m , x )

            worksheet.insert_image('D'+m, "/home/pi/Desktop/images/"+ date + ".jpg", {'x_scale': 0.2, 'y_scale': 0.2})         

            r+=10
            workbook.close()

for row[0] and row[2] i am taking data from other place in the program so now i wanted to save data with the old data in file without overwrite
thank you for your attention and sorry for my bad English

You should check this

https://xlsxwriter.readthedocs.io/getting_started.html

in the documentation of the module you are trying to use it says it cannot read or edit existing files, it only creates new ones, but it cannot edit existing ones, so maybe the problem is in the module you are using. Try getting a module that allows you to edit excel files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM