3

I am using Python in a Linux (Ubuntu) environment.

How do I go about reading the comment that is stored in cell A5 in spreadsheet MyFile.xls (in case it matters, this file in in Excel 2003 format)?

1
  • When you did a Google search for reading XLS files in Python, what were the first few links? Which of those open source projects looked good to you? Do you have a specific question on how xlrd works? Commented May 18, 2011 at 15:15

2 Answers 2

3

I was going to say that it's too bad that xlrd doesn't handle comments, but then I stumbled upon this What's the best way to extract Excel cell comments using Perl or Ruby?.

Key passage:

The Python xlrd library will parse cell comments (if you turn on xlrd.sheet.OBJ_MSO_DEBUG, you'll see them), but it doesn't expose them from the API. You could either parse the dump or hack on it a bit so you can get to them programmatically.

Sign up to request clarification or add additional context in comments.

8 Comments

@Steven Rumbalski: thank you. Can you perhaps provide an example how to do this? I know how to use xlrd, yet am not sure how to implement the changes you suggested.
@user3262424 There's the rub. It doesn't work out of the box and requires some mucking about -- more than I'm prepared to do for an answer. If you refer to the answer I linked to you will see that much of the work has been done for you, you just have to learn how to read a diff.
@user3262424 If this is too difficult you might need to pay someone to do it. Or perhaps you could see if this capability exists in excel libraries for ruby or perl or something. Or you could automate openoffice to open the file and extract the comment.
@user3262424 The python module for OpenOffice is called uno. I think it's crap--it's both unwieldy and unintuitive. I included it in my answer merely for completeness. I think the xlrd hack is your best option. I'd be happy if someone else came up with a better answer.
@i_4_got: Nice catch. Looking at source and revision history cell_note_map was added in version 0.7.2 which was released 2012-01-14.
|
3

You can read Notes by using sheet.cell_note_map easy.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.