OfficeDoc reads/writes/appends and formats data, images & figure screenshots in Microsoft Office documents, from within the Matlab environment. Supported document formats include XLS (Excel), DOC (Word) & PPT (PowerPoint). Opening/closing COM server connection and files is user-controllable, enabling very fast sequential writes. Numerous format properties enable highly customizable output.
This function is meant as a direct replacement for Matlab's built-in xlsread/xlswrite functions. There is no comparable built-in Matlab support for DOC/PPT.
OfficeDoc has 2 basic syntaxes:
The first syntax is the main usage form. Due to the vast number of possible actions and properties, an extensive documentation facility was built-in: the second syntax form above.
- [data,status,errMsg] = officedoc(file, action, propName,propVal, ...)
- actions: 'open'/'read'/'write'/'format'/'close'/'display'
- properties: 66 different props - too many to list here (see inline documentation). The Professional version enables all properties, whereas the demo version enables only a handful. Click here to see the full list of properties.
- helpText = officedoc('help', helpType)
- helpTypes: 'props'/'examples'/'xls'/'doc'/'ppt'
OfficeDoc comes a long way in enabling highly customizable document output. However, there will always be certain unsupported capabilities. The built-in documentation provides examples on accessing and using such features via direct COM calls.
A basic usage example follows. Click here for more detailed examples:
>> [file,status] = officedoc(fileName, 'open', 'mode','append');
>> status = officedoc(file, 'write', 'title','My data', 'data',[1,2;3,4], 'image',gcf, 'bold',1,'fgcolor','b');
>> status = officedoc(file, 'close');
Bugs and suggestions:
OfficeDoc was tested on Office 11 (XP) & Matlab 6.0 (R12) - 7.4 (R2007a), but might also work on earlier versions of Matlab & Office. OfficeDoc was only tested on Windows PC, and is expected to fail on other systems. Please report any incompatibilities or other bugs/suggestions to YMASoftware@gmail.com.