# The compdoc Module

Implements the minimal functionality required to extract a "Workbook" or "Book" stream (as one big string) from an OLE2 Compound Document file.

Copyright © 2005-2012 Stephen John Machin, Lingfo Pty Ltd

This module is part of the xlrd package, which is released under a BSD-style licence.

## Module Contents

CompDoc(mem, logfile=sys.stdout, DEBUG=0) (class) [#]

  Compound document handler.

  mem
    The raw contents of the file, as a string, or as an mmap.mmap() object. The only operation it needs to support is slicing.

  For more information about this class, see The CompDoc Class.

SIGNATURE (variable) [#]

  Magic cookie that should appear in the first 8 bytes of the file.

## The CompDoc Class

CompDoc(mem, logfile=sys.stdout, DEBUG=0) (class) [#]

  Compound document handler.

  mem
    The raw contents of the file, as a string, or as an mmap.mmap() object. The only operation it needs to support is slicing.
get_named_stream(qname) [#]

  Interrogate the compound document's directory; return the stream as a string if found, otherwise return None.

  qname
    Name of the desired stream e.g. u'Workbook'. Should be in Unicode or convertible thereto.
locate_named_stream(qname) [#]

  Interrogate the compound document's directory. If the named stream is not found, (None, 0, 0) will be returned. If the named stream is found and is contiguous within the original byte sequence ("mem") used when the document was opened, then (mem, offset_to_start_of_stream, length_of_stream) is returned. Otherwise a new string is built from the fragments and (new_string, 0, length_of_stream) is returned.

  qname
    Name of the desired stream e.g. u'Workbook'. Should be in Unicode or convertible thereto.