3

i know my question is quite strange but i have a problem,

When i try to put "toto" at line a5, it suppress all my old data. there is my code (i just followed the documentation).

import xlsxwriter
 
# Workbook() takes one, non-optional, argument
# which is the filename that we want to create.
workbook = xlsxwriter.Workbook('hello.xlsx')
 
# The workbook object is then used to add new
# worksheet via the add_worksheet() method.
worksheet = workbook.add_worksheet()
 
# Use the worksheet object to write
# data via the write() method.
worksheet.write('A4', 'Hello..')
worksheet.write('B1', 'Geeks')
worksheet.write('C1', 'For')
worksheet.write('D1', 'Geeks')
 
# Finally, close the Excel file
# via the close() method.
workbook.close()

that code functions, but i would like to add some elements after this. When i retry the function with differents values, it deletes the hello on a4 etc how can i do? Thanks for yours answer,

3
  • 2
    do you want to update the data?? or always add a new worksheet? Commented Sep 14, 2021 at 22:06
  • i want to update the data. Robxon a user said me its impossible, i have to use openpyxl Commented Sep 14, 2021 at 22:17
  • ty for your comment Commented Sep 14, 2021 at 22:17

1 Answer 1

7

XlsxWriter can only create new files. It cannot read or modify existing files. There is a module called openpyxl that allows you to read and write to preexisting excel files.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.