💾 OLE File Container Format
Go to file
SheetJS fcc05e3567 version bump 0.10.2: proper directory/FAT analysis
- reprocess directory sector lists if not available
- search now strips out OLE metacharacters \0-\5
- strip sourceMappingURL references from minified scripts (h/t @vinin3)
- added xlscfb.js for js-xls
2014-11-02 23:02:42 -05:00
bin version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00
bits version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00
dist version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00
misc version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00
.gitignore version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00
.jscs.json version bump 0.10.0: performance 2014-06-24 00:00:39 -04:00
.jshintrc version bump 0.6.0: case insensitive find 2013-10-29 11:54:56 -07:00
.travis.yml version bump 0.10.0: performance 2014-06-24 00:00:39 -04:00
LICENSE version bump 0.9.1: massive cleanup 2014-05-20 10:43:03 -07:00
Makefile version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00
README.md version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00
cfb.js version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00
fails.lst version bump 0.10.1: streamlined node module 2014-07-05 12:22:11 -04:00
index.html version bump 0.9.1: massive cleanup 2014-05-20 10:43:03 -07:00
package.json version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00
test.js version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00
xlscfb.js version bump 0.10.2: proper directory/FAT analysis 2014-11-02 23:02:42 -05:00

Compound File Binary Format

This is a Pure-JS implementation of MS-CFB: Compound File Binary File Format, a format used in many Microsoft file types (such as XLS, DOC, and other Microsoft Office file types).

Utility Installation and Usage

The package is available on NPM:

$ npm install -g cfb
$ cfb path/to/CFB/file

The command will extract the storages and streams in the container, generating files that line up with the tree-based structure of the storage. Metadata such as the red-black tree are discarded (and in the future, new CFB containers will exclusively use black nodes)

Library Installation and Usage

In the browser:

<script src="cfb.js" type="text/javascript"></script>

In node:

var CFB = require('cfb');

For example, to get the Workbook content from an XLS file:

var cfb = CFB.read(filename, {type: 'file'});
var workbook = cfb.find('Workbook')

API

Typescript definitions are maintained in misc/cfb.d.ts.

The CFB object exposes the following methods and properties:

CFB.parse(blob) takes a nodejs Buffer or an array of bytes and returns an parsed representation of the data.

CFB.read(blob, options) wraps parse. options.type controls the behavior:

  • file: blob should be a file name
  • base64: blob should be a base64 string
  • binary: blob should be a binary string

Container Object Description

The object returned by parse and read can be found in the source (rval). It has the following properties and methods:

  • .find(path) performs a case-insensitive match for the path (or file name, if there are no slashes) and returns an entry object (described later) or null if not found

  • .FullPaths is an array of the names of all of the streams (files) and storages (directories) in the container. The paths are properly prefixed from the root entry (so the entries are unique)

  • .FullPathDir is an object whose keys are entries in .FullPaths and whose values are objects with metadata and content (described below)

  • .FileIndex is an array of the objects from .FullPathDir, in the same order as .FullPaths.

  • .raw contains the raw header and sectors

Entry Object Description

The entry objects are available from FullPathDir and FileIndex elements of the container object.

  • .name is the (case sensitive) internal name
  • .type is the type as defined in "Object Type" in [MS-CFB] 2.6.1: 2 (stream) for files, 1 (storage) for dirs, 5 (root) for root)
  • .content is a Buffer/Array with the raw content
  • .ct/.mt are the creation and modification time (if provided in file)

Notes

Case comparison has not been verified for non-ASCII characters

Writing is not supported. It is in the works, but it has not yet been released.

The xlscfb.js file is designed to be embedded in js-xls

License

This implementation is covered under Apache 2.0 license. It complies with the Open Specifications Promise

Build Status

Coverage Status

githalytics.com alpha