Reputation: 29
I have taken this basic code for the xlsxwriter website. According to them, this code should open a Excel file with hello written in the A1 square, but nothing seems to have been created and after having scanned my computer for the file my suspicion was confirmed.
import xlsxwriter
workbook = xlsxwriter.Workbook("hello.xlsx")
worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Hello world')
workbook.close()
Upvotes: 1
Views: 9159
Reputation: 849
This code does work:
import xlsxwriter
workbook = xlsxwriter.Workbook(r'C:\hello.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Hello world')
workbook.close()
You should specify where the file to be created will go. For example r'C:\hello.xlsx'
rather than just the name of the file. Also, you need to close the workbook, not the worksheet.
FYI: To format your code, just indent code by four spaces.
Upvotes: 4