PydPiper / pylightxl

A light weight, zero dependency, minimal functionality excel read/writer python library
https://pylightxl.readthedocs.io
MIT License
300 stars 47 forks source link

Error while trying to open a file #53

Closed AndreMPCosta closed 3 years ago

AndreMPCosta commented 3 years ago

Pylightxl Version: 1.56 Python Version: 3.9.1

Summary of Bug/Feature: When trying to open a file, I get invalid literal error.

db = xl.readxl('Lusitania_Recibos.xlsx')
print(db.ws(ws='Sheet1').address(address='A7'))

If I open the file and save it on Excel, the above 2 lines work, so I don't know what's the issue (The file was downloaded from somewhere else, it is a generated file). But I want to be able to use this without having Excel, or having to open the file and save it.

Traceback:

Traceback (most recent call last):
  File "D:\FolhaCaixa2\lusitania\api.py", line 46, in <module>
    lusitania.convert()
  File "D:\FolhaCaixa2\utils.py", line 89, in convert
    db = xl.readxl('Lusitania_Recibos.xlsx')
  File "C:\Users\Andre\.virtualenvs\FolhaCaixa2-LlgGVunk\lib\site-packages\pylightxl\pylightxl.py", line 119, in readxl
    wb_rels = readxl_get_workbook(fn)
  File "C:\Users\Andre\.virtualenvs\FolhaCaixa2-LlgGVunk\lib\site-packages\pylightxl\pylightxl.py", line 235, in readxl_get_workbook
    sheetId = int(rId.replace('rId', ''))
ValueError: invalid literal for int() with base 10: 'GemRid775394'

Suggestion for fix:

PydPiper commented 3 years ago

Hi @AndreMPCosta thank you for considering using pylightxl. I see that the issue is caused by the unique sheedID conversion. The standard excel generated format is rID#, it looks like your generated excel does not follow this convention. Can you confirm that your spreadsheet can be opened by excel without a warning? If so then we can work on adding this support on the next release

AndreMPCosta commented 3 years ago

Hey, I can confirm that I can open the file in Excel without any warning.

sbardian commented 3 years ago

getting the same error. is this being addressed in the next release? Thanks!

PydPiper commented 3 years ago

@AndreMPCosta @sbardian thank you for your patience, please download the latest version of pylightxl v1.57 that will have the fix to this issue. Thank you for submitting it and making pylightxl better for it!

sbardian commented 3 years ago

Thanks @PydPiper ! Will give it a go.

sbardian commented 3 years ago

@PydPiper not sure this will solve the issue for me? It may fix for the sheet ID listed in the issue "GemRid775394", the ID I'm getting is in the format "R47fd958b504b4526" and still breaks when calling int() on the result of the split?

AndreMPCosta commented 3 years ago

@AndreMPCosta @sbardian thank you for your patience, please download the latest version of pylightxl v1.57 that will have the fix to this issue. Thank you for submitting it and making pylightxl better for it!

I've had kind of a rush of dealing with those excels files, so I've switched to another lib, but I hope it helped tackling the issue for whoever encountered it! Thanks for fixing it (can't test now).