Search code examples
pythonexcelxlsxwriterlibreoffice

Why does xlsxwriter write ' at the start of my cells


it is my code:

import xlsxwriter

# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('Expenses01.xlsx')
worksheet = workbook.add_worksheet()

# Some data we want to write to the worksheet.


# Write a total using a formula.
worksheet.write_string(0, 0, '99999999001')
worksheet.write_string(0, 1, '99999999001')
worksheet.write_string(0, 2, '99999999001')
worksheet.write_string(0, 3, '99999999001')
worksheet.write_string(0, 4, '99999999001')
worksheet.write_string(0, 5, '99999999001')

workbook.close()

I am using

Ubuntu 20.04.2 LTS

XlsxWriter==3.0.1

LibreOffice Calc Version: 6.4.7.2

In Libre office cells contains this: '99999999001 - why XlsxWriterr add apostophe to start of my cells?

enter image description here


Solution

  • The apostrophe before your number in Libreoffice just notes that the cell format is of type text. It isn't actually a part of the cell's content. See this link for more information: https://forum.openoffice.org/en/forum/viewtopic.php?f=9&t=49046

    Just for demonstration, when opening your generated file in Microsoft Excel there are no apostrophes there:

    enter image description here