7

I am relatively new to python and I am trying to read information from an excel sheet to generate a graph. So far I am using the most current version of the xlrd library (0.9.4) in a nested for loop to grab the value from each cell. However, I am unsure how to access the formatting information for each cell

For example, if a cell were formatted to display as currency in the excel file, using the standard sheet.cell(row, column).value from xlrd would only return 5.0 instead of $5.00

I found here that you can set the formatting_info parameter to true when opening the workbook in order to see some of the format information, however I am primarily using excel 2013 and my excel sheets are being saved by default as .xlsx files. According to this issue on GitHub, support for formatting_info has not yet been implemented for .xlsx files.

Is there any way around using the formatting_info flag, or any other way that I can detect when a format, currency specifically, has been used in order to reflect that in my graphs? I am aware that it is possible to convert .xlsx files to .xls files such as shown here, but I am concerned about information/formatting loss.

Community
  • 1
  • 1
sidepocket
  • 71
  • 3
  • Your formattting information still remains the same even if you convert a `.xlsx` file to `.xls`. `.xlsx` is essentially is a more optimized way to store the data. You can see the difference in sizes when you convert a `.xlsx` file to `.xls` format. `.xls` size will be bigger than `.xlsx`. – manty Feb 08 '16 at 08:41
  • xlrd no longer supports XLSX files. Please have a look at openpyxl. This SO answer https://stackoverflow.com/questions/53930645/extract-xlsx-workbook-file-metadata-properties-in-python-3-6 provides a few ideas to access meta data. Else consider the openpyxl docs https://openpyxl.readthedocs.io/en/stable/index.html – RndmSymbl May 29 '21 at 11:12

0 Answers0