xlrd

Fails to read the value of formular after using xlsxwriter to close and then usinging xlrd to read the excel file

眉间皱痕 提交于 2019-12-24 17:18:00
问题 At fisrt, I use xlsxwriter to write a simple formula in one cell and close the *.xlsx file. Then I try to read the value of the cell but only read '0' from the cell using xlrd at the same program. If I read some fixed values (like string or constant number) in a cell, it works well. If I create a formula cell manually in a *.xlsx file, the xlrd can also get the value of the formula. It seems that I cannot read the value of formula cell only when I write a forumla to *.xlsx and then read it in

how to read formulas with xlrd

戏子无情 提交于 2019-12-24 04:28:09
问题 I am trying to do a parser, that reads several excel files. I need values usually at the bottom of a row where you find a sum of all upper elements. So the cell value is actually "=sum()" or "A5*0.5" lets say... To a user that opens this file with excel it appears like a number, which is fine. But if I try to read this value with ws.cell(x, y).value I do not get anything. So my question is how to read this kind of fields with xlrd, if it is possible to read it like ws.cell(x, y).value or

xlrd - Error “Workbook is encrypted”, Python 3.2.3

限于喜欢 提交于 2019-12-24 03:37:41
问题 I have a short program that collects a list of all .xls files in folder/sub-folders and then I loop through the file list, opening each xls document (Try: book = xlrd.open_workbook(f) ) to look for specific information. If an exception is thrown, I write out the filename to an exception list. What I am finding is that I have a LOT of files that xlrd throws the error : Traceback (most recent call last): File "<pyshell#5>", line 1, in <module> book = xlrd.open_workbook(f) File "C:\Python32\lib

Getting the URL from Excel Sheet Hyper links in Python with xlrd

大城市里の小女人 提交于 2019-12-24 00:57:08
问题 I am trying to get the hyperlinks URL of elements in the 2nd column of an Excel sheet using xlrd. When using: book = open_workbook('mypath', formatting_info=True) sheet = book.sheet_by_index(0) r_sheet = book.sheet_by_index(0) wb = copy(book) w_sheet = wb.get_sheet(0) for row_index in range(1, sheet.nrows): URL = sheet.hyperlink_map.get((row_index, 1)) print URL I get: <xlrd.sheet.Hyperlink object at 0x0000000002D81898> <xlrd.sheet.Hyperlink object at 0x0000000002D819E8> <xlrd.sheet.Hyperlink

Delete column from xls file [closed]

僤鯓⒐⒋嵵緔 提交于 2019-12-23 05:12:48
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . Using Python, I need to be able to do the following operations to a workbook for excel 2007: 1.delete colums I am looking into xlrd; however. Can anyone please tell me how could do this? 回答1: If you're working in Python 3.x, you'll find a lot of trouble using the xlrd / xlwt /

change name of an excel worksheet after reading the file in python

て烟熏妆下的殇ゞ 提交于 2019-12-23 05:06:44
问题 hi im using the xlrd module to read an excel file. How can i rename the first worksheet of each excel file. Thank you. 回答1: I don't think you can modify files with either xlrd or xlwt . You can however copy the file with xlrd and then modify and write the copy with xlwt . Here's an example adapted from here: writing to existing workbook using xlwt: from xlutils.copy import copy from xlrd import open_workbook # open the file you're interested rb = open_workbook('some_document.xlsx') # copy it

Read workbook properties using python and xlrd

大憨熊 提交于 2019-12-22 08:33:57
问题 Is there a way to read the excel file properties using xlrd? I refer not to cell presentation properties, but general workbook properties. Thanks a lot in advance. 回答1: Apart from the username (last person to save the worksheet) the Book instance as returned by open_workbook does not seem to have any properties. I recursively dumped the Book ( dumping its dict if a xlrd.BaseObject) and could not find anything in that way. The test files for sure had an author, company and some custom metadata

Python: open existing Excel file and count rows in sheet

我与影子孤独终老i 提交于 2019-12-22 07:05:35
问题 I have an existing Excel file. I want to load that one and get the count of rows in this sheet, to later write in the next row of this sheet and save it again. I get following error messages: AttributeError: 'Worksheet' object has no attribute 'nrows' But clearly this method exists, coz everyone is using it to get the count. The Code I wrote looks like this: def write_xls_result(test_case): testCase = re.sub("/", "_", test_case) automation_report = os.path.expanduser("~/Library/pathtofile

python xlrd receiving float from excel text cell

瘦欲@ 提交于 2019-12-22 06:41:50
问题 I am attempting to read values from an Excel file using xlrd. It has been working great on dates, numbers, and up until now text. I have a column (category) with cells containing text (the cells are formatted as text). When I print out the cell value a float is displayed instead of the text. I also printed out the ctype of the Cell object(s) to check and it is showing as Number. I've read through the documentation and tutorial of xlrd and can't seem to find why this is occurring. Could it be

Python Xlrd and Xlwt

那年仲夏 提交于 2019-12-22 01:04:07
问题 I have the following content in an old Excel sheet: I need to generate a new Excel sheet with the following values: In the input Excel file's 3rd column I have a range 10010-10040 and an increment value of 10 . This needs to be expanded in my new Excel file. If I give a comma (,) in between values, it should be treated as separate values and expanded. (Like in row2, column 3) I have no idea how to do this and I am new to Python. 回答1: Try the following. This uses the xlrd and xlwt libraries to