0

For the past day i've been trying to get openpyxl or any other python excel library to read the cell value. But every time i run the program it returns with None if i set it to data_only = True. If i dont add the data_only it only returns the formula im using. This is my code:

 wb = xl.load_workbook(str(tm.strftime("%d-%m-%Y")) + ' - ' + str(tm.strftime("%A")) + '.xlsx')
 ws = wb.active

bag = float(self.entryBags.get())
ws['B3'] = bag

wb.save(str(tm.strftime("%d-%m-%Y")) + ' - ' + str(tm.strftime("%A")) + '.xlsx')

wb2 = xl.load_workbook(str(tm.strftime("%d-%m-%Y")) + ' - ' + str(tm.strftime("%A")) + '.xlsx', data_only = True)

ws2 = wb2.active

total_till = ws2['B13']

print(total_till.value)

If any one can give any suggestions on how to read the cell value, using openpyxl or any other python library, it would be very helpful.

Thanks

ashkl
  • 47
  • 1
  • 9
  • 1
    Shouldn't that be `ws2['B3']` instead of `ws2['B13']`? Also, create a dedicated variable called `path`, makes your code more readable. How does it look when you open the saved workbook `wb` in Excel? – Elmex80s Feb 25 '17 at 01:54
  • Read this http://stackoverflow.com/questions/42376662/openpyxl-2-4-2-cell-value-generated-by-formula-empty-after-saving. I guess you aspects recalulating of formula within openpyxl. – stovfl Feb 25 '17 at 16:28
  • Presumably there is not cached value in the cells you're looking at. – Charlie Clark Feb 27 '17 at 09:34

0 Answers0