OfficeDoc full help text

OFFICEDOC read/write/append/format/display data in Microsoft Office documents (XLS/DOC/PPT)

Syntax:

  [file,status,errMsg] = officedoc(fileName, 'open',   propName,propValue,...)
  [data,status,errMsg] = officedoc(file,     'read',   propName,propValue,...)
       [status,errMsg] = officedoc(file,     'write',  propName,propValue,...)
       [status,errMsg] = officedoc(file,     'format', propName,propValue,...)
       [status,errMsg] = officedoc(file,     'close',  propName,propValue,...)
                         officedoc(file,     'display', visibleFlag)

              helpText = officedoc('help', helpType)

officedoc reads/writes/appends and formats data, images and screenshots in Microsoft Office documents. Supported formats include XLS (Excel), DOC (Word) and PPT (PowerPoint). Opening/closing COM server connection and files is user-controllable, enabling very fast sequential writes. Numerous format properties enable highly-customizable output.

[FILE, STATUS, ERRMSG] = officedoc(FILENAME, 'open', ...) opens the specified FILENAME for later reading/writing. The returned FILE struct may be used later to read/write/format file data. The optional STATUS output argument is 0 in case of sucess or -1 in case of error, when the error message is specified in another optional argument ERRMSG. The document format is determined from the FILENAME extension (xls, doc or ppt). Use the optional properties to set open mode etc.

[DATA, STATUS, ERRMSG] = officedoc(FILE, 'read', ...) reads DATA from specified FILE, a struct that was returned from officedoc(...,'open'). The basic DATA format is a structure based on the top-level division of the document (worksheets, chapters or slides, depending on file format). The structure fields are the division names and the field contents is the data within them. If only a single division was found or requested, then DATA contains the division's data immediately (not contained within a structure). STATUS is -1 in case of error, or the actual number of data elements/characters read in case of success.

officedoc(FILE, 'write', ...) writes data to the specified FILE. Use the optional properties to specify range and data. If no range is specified, then the last file position (before file was last closed) will be used (XLS/DOC only, not PPT). STATUS is -1 in case of error, or actual number of data elements/characters writen in case of success. Formating properties may be specified for the written data, saving a separate officedoc(FILE, 'format', ...) command.

officedoc(FILE, 'format', ...) formats data in the specified FILE. Use the optional properties to specify range and format options.

officedoc(FILE, 'close', ...) closes the specified FILE. Use the optional properties to specify closing properties.

officedoc(FILE, 'display', VISIBLEFLAG) displays the specified FILE in a corresponding MS Office application. If FILE is closed, then FILENAME should be used instead. VISIBLEFLAG is an optional flag determining visibility: true/1/'on' (=default) means display; false/0/'off'=hide. You can also specify this as an officedoc(...,'open',...) property. Note: PPT should remain visible or some features fail (ok in DOC/XLS)

officedoc(..., propName,propValue, ...) sets the property value(s) for the specified file action. Property specification order does not matter. PropNames are always case-insensitive, but in a few cases propValues might be case-sensitive. Some props are not supported by one or more doc types: such properties are simply ignored if irrelevant. 66 different properties are supported (more in future versions). Type "officedoc help props" to see the full list of supported properties.

officedoc comes a long way in enabling highly-customizable document output. However, there will always be certain unsupported Office features. Type "officedoc help examples" to see examples of accessing and using such features via direct COM calls.

officedoc('help',HELPTYPE) displays extended help on officedoc usage: - officedoc('help') displays this help section (same as "help officedoc") - officedoc('help','props') describes all the supported propNames - officedoc('help','examples') displays officedoc usage examples - officedoc('help','xls') displays only help relevant to XLS (or 'ppt','doc')

Examples:

type "officedoc help examples"

Known Limitations:

  1. OPEN: PPT must remain visible or else some features fail
  2. READ: Missing DivType='headings' (DOC)
  3. READ: Disregards specified page/line/range (DOC)
  4. READ: Cannot read non-text data (images, tables and other complex formats)
  5. FORMAT: Edge properties fail in Matlab 6 (R12) due to a bug in Maltab's ActiveX implementation (ok in later versions) (XLS)
  6. FORMAT: Lots of missing properties that could be added (XLS/DOC/PPT)
  7. officedoc is designed to work on Windows machines (might work on Macs)

Bugs and suggestions:

officedoc was tested on Office 11 (XP) and Matlab 6.0 (R12) - 7.4 (R2007a) but might also work on earlier versions of Matlab and Office. Please report any incompatibilities or other bugs/suggestions to: YMASoftware@gmail.com

Change log:

See also:

xlsread, xlswrite, xlswrite1, docSave, pptSave (last 3 on the File Exchange - ids 340,3149,10465)

Back to OfficeDoc product page