1

Here is some example xlsxwriter code to write into the worksheet:

workbook = xlsxwriter.Workbook('example.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Hello')
worksheet.write('A2', 'World', bold)

What may be noticed immediately is the cell to write must always be specified. Is there a way to write to the next empty cell, or perhaps a workaround to write to an empty cell? Say I wanted to write to our next empty cell no matter where in column A it was. Is there a way to do this?

G Sarala
  • 21
  • 1
  • 5

2 Answers2

2

A naive approach would expect something like read the values of the cells till you find an empty one and then write there, but this is not actually possible with XlsxWriter.

It looks like you need to keep track of the cells where you are writing or, if you are writing in a file which already contains info, you need to find another solution like these, suggested in the XlsxWriter documentation.

mucio
  • 7,014
  • 1
  • 21
  • 33
-1

As per my understanding from the question, the ask is that we would to leave first line empty in the excel file.

I am not sure about my understanding of this question as the code was unexpectedly very easy, please try below:

import xlsxwriter
workbook = xlsxwriter.Workbook('example.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A2', 'India is Great')
workbook.close()

Please feel free to add your comments here, I can try to provide some solution/alternate in case I missed anything here.

amandeep1991
  • 1,344
  • 13
  • 17