Open TibbersGo opened 3 years ago
How can I fit python to read the xlsx file generated by pyecelerate? I tested several reading xlsx-related libraries, but they could not be read normally.
Do you have some code to reproduce this issue? This is a bit curious.
This is the demo I used
from pyexcelerate import Workbook
workbook = Workbook()
data=[]
for j in range(100):
data_list = ['a', 'b', 'c', 'd', 'e']
data.append(data_list)
workbook.new_sheet("sheet1", data=data)
workbook.save("demo.xlsx")
from openpyxl import load_workbook
wb_data = load_workbook('demo.xlsx', read_only=True)
sheet = wb_data["sheet1"]
print(sheet.max_row)
print(sheet.cell(row=2, column=2).value)
When I use openpyxl to read the file, I cannot get the maximum number of rows of the file. Openpyxl will return "None".Although the maximum number of rows cannot be obtained, the value of the cell can be obtained.
@TibbersGo to fix dimensions you should call sheet.calculate_dimension()
according to openpyxl documentation
@TibbersGo thanks for the example, I missed the notification email so apologies for the delay. It does seem that PyExcelerate isn't setting some metadata correctly here so we should get this fixed. That being said I'm a bit tight on bandwidth. If you're interested in contributing we'd welcome a contribution here.
From the openpyxl source it seems that just a specific element needs to be set in the xml: https://github.com/chronossc/openpyxl/blob/master/openpyxl/reader/worksheet.py#L56
I save the same file as another file with excel, and then it can be read with openpyxl, so I suspect that there is a problem with the pyexcelerate export file. How can I solve it?