Thiyagu
Thiyagu

Reputation: 133

AttributeError: 'Worksheet' object has no attribute 'hide_gridlines'

I am trying to run a Python code which was written by my colleague who has now moved out, the same piece of code is running in my machine successfully. But when I run it in other machine it is failing with error

AttributeError: 'Worksheet' object has no attribute 'hide_gridlines'

Not sure what this piece of code does, also not sure if it is dependent on any excel packages like xlrd, openpyxl. But I have tried with various versions of xlrd and openpyxl.

Couldn't find any help in the internet. Can you please shed some light?

I am using Python 3.8.5

def writeToExcel(ReportPath, SummaryDf, ExecutionDf):
    writer = pd.ExcelWriter(ReportPath)
    SummaryDf.to_excel(writer, sheet_name='Report', startcol=1, startrow=1, index=True)
    ExecutionDf.to_excel(writer, sheet_name='Report',startcol=0, startrow=10, index=False)
    workbook = writer.book
    worksheet = writer.sheets['Report']
    worksheet.hide_gridlines(2)

Upvotes: 1

Views: 1026

Answers (2)

Thiyagu
Thiyagu

Reputation: 133

I pip installed the XlsxWriter library. It worked like a charm!

Upvotes: 1

Mikhail Vladimirov
Mikhail Vladimirov

Reputation: 13890

Function hide_gridlines was added into XlsxWriter library in version 0.0.4. Probably, the other machine has older version installed. Check the currently installed version and upgrade if necessary.

Upvotes: 1

Related Questions