1

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

How do I go about writing a comment into a cell in an Excel file (say,MyFile.xls)?

I know that it is possible to write values. Yet, how do I go about writing a comment?

12
  • 1
    Does it have to be .xls or can you use .xlsx? Commented May 23, 2011 at 17:58
  • .xls is much preferred (as I don't have Office 2007). Commented May 23, 2011 at 18:01
  • Too bad. .xlsx is just XML files in a zip archive, and Python knows how to deal with both of those. .xls is much harder. Commented May 23, 2011 at 18:04
  • 2
    Every cell has its contents; yet, in addition to the actual contents, every cell can contain a comment. my question was, how do I get (from within python) to write a comment for some cell? Commented May 23, 2011 at 19:03
  • 3
    John Machin occasionally visits SO, and he can probably confirm one way or the other; but as far as I'm aware, xlrd/xlwt don't handle cell comments. Comments aren't simple to handle, as they can contain rich, formatted text; and the structures within the .xls file changed quite dramatically between BIFF5 and BIFF8... adding to the complexities of handling them. Commented May 23, 2011 at 21:01

2 Answers 2

3

On Windows (with Excel installed) you could use COM from Python: this class wraps it nicely for you.

But on Linux, you'll need to use xlwt.

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

Comments

1

I'm looking into this myself and found https://bitbucket.org/ericgazoni/openpyxl/wiki/Home . It is a new library that allows editing xlsx files. I'm not sure if it allows editing comments though.

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.