@@ -4,7 +4,7 @@ This is a Pure-JS implementation of MS-CFB: Compound File Binary File Format, a
4
4
format used in many Microsoft file types (such as XLS, DOC, and other Microsoft
5
5
Office file types).
6
6
7
- # Installation and Usage
7
+ # Utility Installation and Usage
8
8
9
9
The package is available on NPM:
10
10
@@ -18,6 +18,79 @@ files that line up with the tree-based structure of the storage. Metadata
18
18
such as the red-black tree are discarded (and in the future, new CFB containers
19
19
will exclusively use black nodes)
20
20
21
+ # Library Installation and Usage
22
+
23
+ In the browser:
24
+
25
+ <script src="cfb.js" type="text/javascript"></script>
26
+
27
+ In node:
28
+
29
+ var CFB = require('cfb');
30
+
31
+ For example, to get the Workbook content from an XLS file:
32
+
33
+ var cfb = CFB.read(filename, {type: 'file'});
34
+ var has_vba = cfb.Directory['Workbook']
35
+
36
+ ## API
37
+
38
+ The CFB object exposes the following methods and properties:
39
+
40
+ ` CFB.parse(blob) ` takes a nodejs Buffer or an array of bytes and returns an
41
+ parsed representation of the data.
42
+
43
+ ` CFB.read(blob, options) ` wraps ` parse ` . ` options.type ` controls the behavior:
44
+
45
+ - ` file ` : ` blob ` should be a file name
46
+ - ` base64 ` : ` blob ` should be a base64 string
47
+ - ` binary ` : ` blob ` should be a binary string
48
+
49
+ ## Container Object Description
50
+
51
+ The object returned by ` parse ` and ` read ` can be found in the source (` rval ` ).
52
+ It has the following properties and methods:
53
+
54
+ - ` .find(path) ` performs a case-insensitive match for the path (or file name, if
55
+ there are no slashes) and returns an entry object (described later) or null if
56
+ not found
57
+
58
+ - ` .FullPaths ` is an array of the names of all of the streams (files) and
59
+ storages (directories) in the container. The paths are properly prefixed from
60
+ the root entry (so the entries are unique)
61
+
62
+ - ` .FullPathDir ` is an object whose keys are entries in ` .FullPaths ` and whose
63
+ values are objects with metadata and content (described below)
64
+
65
+ - ` .FileIndex ` is an array of the objects from ` .FullPathDir ` , in the same order
66
+ as ` .FullPaths ` .
67
+
68
+ - ` .raw ` contains the raw header and sectors
69
+
70
+ - ` .Paths ` is an array of the names of all of the streams (files) and storages
71
+ (directories) in the container. There is no disambiguation in the case of
72
+ streams with the same name.
73
+
74
+ - ` .Directory ` is an object whose keys are entries in ` .Paths ` and whose values
75
+ are objects with metadata and content. Since collisions are not properly
76
+ handled here, ` .FullPathDir ` is the better option for new projects.
77
+
78
+ ## Entry Object Description
79
+
80
+ The entry objects are available from ` FullPathDir ` , ` FileIndex ` , and ` Directory `
81
+ elements of the container object.
82
+
83
+ - ` .name ` is the (case sensitive) internal name
84
+ - ` .type ` is the type (` stream ` for files, ` storage ` for dirs, ` root ` for root)
85
+ - ` .content ` is a Buffer/Array with the raw content
86
+ - ` .ct ` /` .mt ` are the creation and modification time (if provided in file)
87
+
88
+ # Notes
89
+
90
+ Case comparison has not been verified for non-ASCII character
91
+
92
+ Writing is not supported. It is in the works, but it has not yet been released.
93
+
21
94
# License
22
95
23
96
This implementation is covered under Apache 2.0 license. It complies with the
0 commit comments