0

new to python(v3.11) and xlsxwriter (v3.08) ,

looking to find an example python code with xlsxwriter

  1. open an existing xlsx sheet - which has headings,formated cells to suit headings size ready to populate worksheet
  2. write/ overwrite cells in thw worksheet except headings/formated cells workbook
  3. save the updated xlsx file

so far examples found show how to create/write/ save a new xlsx, but not how to populate an existing whorksheet with data

Regards

Will

workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()
 
worksheet.write('A1', 'Hello..')
worksheet.write('B1', 'Geeks')
worksheet.write('C1', 'For')
worksheet.write('D1', 'Geeks')
workbook.close()
sure will
  • 9
  • 1
  • The name of the module `XlsxWriter` has in it exactly what it is: It is a writer of `.xlsx` files. As in, it writes, it doesn't read. I've fallen down that same trap thinking that it could read them as well. The documentation for `XlsxWriter` has some alternatives that you could look into instead. [You can find the link to that page here](https://xlsxwriter.readthedocs.io/alternatives.html#alternatives) – Hampus Larsson Mar 09 '23 at 06:15
  • Does this answer your question? [xlsxwriter: is there a way to open an existing worksheet in my workbook?](https://stackoverflow.com/questions/18002133/xlsxwriter-is-there-a-way-to-open-an-existing-worksheet-in-my-workbook) – Hampus Larsson Mar 09 '23 at 06:19
  • thanks , so looking at open OPENPYXL , it allows for read of the xlsx file , but does that mean also that the headings in the file MUST be read and then headings rewritten with the data to populate the worksheet ? – sure will Mar 09 '23 at 19:40
  • @sure will The Excel sheet is populated with whatever in each cell; value, formula or None and remains as that unless you delete or overwrite it with another value, formula or None. – moken Mar 20 '23 at 02:49
  • so only the cells i wish to update get written , and the heading cells will remain as is , with their formating etc – sure will Mar 21 '23 at 03:12

0 Answers0