{"id":13725208,"url":"https://github.com/SheetJS/js-cfb","last_synced_at":"2025-05-07T19:33:06.322Z","repository":{"id":466531,"uuid":"12626004","full_name":"SheetJS/js-cfb","owner":"SheetJS","description":":floppy_disk: OLE File Container Format","archived":false,"fork":false,"pushed_at":"2022-11-10T17:17:27.000Z","size":573,"stargazers_count":69,"open_issues_count":7,"forks_count":15,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-29T22:37:40.443Z","etag":null,"topics":["biff","cfb","file-format","mhtml","storage","xls"],"latest_commit_sha":null,"homepage":"https://sheetjs.com/cfb-editor","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SheetJS.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-05T18:55:32.000Z","updated_at":"2024-09-06T05:41:42.000Z","dependencies_parsed_at":"2023-01-13T10:21:30.152Z","dependency_job_id":null,"html_url":"https://github.com/SheetJS/js-cfb","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SheetJS%2Fjs-cfb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SheetJS%2Fjs-cfb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SheetJS%2Fjs-cfb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SheetJS%2Fjs-cfb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SheetJS","download_url":"https://codeload.github.com/SheetJS/js-cfb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224405070,"owners_count":17305711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["biff","cfb","file-format","mhtml","storage","xls"],"created_at":"2024-08-03T01:02:15.787Z","updated_at":"2024-11-14T15:30:51.516Z","avatar_url":"https://github.com/SheetJS.png","language":"JavaScript","readme":"# Container File Blobs\n\nPure JS implementation of various container file formats, including ZIP and CFB.\n\n[![Build Status](https://travis-ci.org/SheetJS/js-cfb.svg?branch=master)](https://travis-ci.org/SheetJS/js-cfb)\n[![Coverage Status](http://img.shields.io/coveralls/SheetJS/js-cfb/master.svg)](https://coveralls.io/r/SheetJS/js-cfb?branch=master)\n[![Dependencies Status](https://david-dm.org/sheetjs/js-cfb/status.svg)](https://david-dm.org/sheetjs/js-cfb)\n[![NPM Downloads](https://img.shields.io/npm/dt/cfb.svg)](https://npmjs.org/package/cfb)\n[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-cfb?pixel)](https://github.com/SheetJS/js-cfb)\n\n## Installation\n\nIn the browser:\n\n```html\n\u003cscript src=\"dist/cfb.min.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n```\n\nWith [npm](https://www.npmjs.org/package/cfb):\n\n```bash\n$ npm install cfb\n```\n\nThe `xlscfb.js` file is designed to be embedded in [js-xlsx](https://github.com/SheetJS/sheetjs)\n\n\n## Library Usage\n\nIn node:\n\n```js\nvar CFB = require('cfb');\n```\n\nFor example, to get the Workbook content from an Excel 2003 XLS file:\n\n```js\nvar cfb = CFB.read(filename, {type: 'file'});\nvar workbook = CFB.find(cfb, 'Workbook');\nvar data = workbook.content;\n```\n\n\n## Command-Line Utility Usage\n\nThe [`cfb-cli`](https://www.npmjs.com/package/cfb-cli) module ships with a CLI\ntool for manipulating and inspecting supported files.\n\n\n## JS API\n\nTypeScript definitions are maintained in `types/index.d.ts`.\n\nThe CFB object exposes the following methods and properties:\n\n`CFB.parse(blob)` takes a nodejs Buffer or an array of bytes and returns an\nparsed representation of the data.\n\n`CFB.read(blob, opts)` wraps `parse`.\n\n`CFB.find(cfb, path)` performs a case-insensitive match for the path (or file\nname, if there are no slashes) and returns an entry object or null if not found.\n\n`CFB.write(cfb, opts)` generates a file based on the container.\n\n`CFB.writeFile(cfb, filename, opts)` creates a file with the specified name.\n\n### Parse Options\n\n`CFB.read` takes an options argument.  `opts.type` controls the behavior:\n\n| `type`     | expected input                                                  |\n|------------|:----------------------------------------------------------------|\n| `\"base64\"` | string: Base64 encoding of the file                             |\n| `\"binary\"` | string: binary string (byte `n` is `data.charCodeAt(n)`)        |\n| `\"buffer\"` | nodejs Buffer                                                   |\n| `\"file\"`   | string: path of file that will be read (nodejs only)            |\n| (default)  | buffer or array of 8-bit unsigned int (byte `n` is `data[n]`)   |\n\n\n### Write Options\n\n`CFB.write` and `CFB.writeFile` take options argument.\n\n`opts.type` controls the behavior:\n\n| `type`     | output                                                          |\n|------------|:----------------------------------------------------------------|\n| `\"base64\"` | string: Base64 encoding of the file                             |\n| `\"binary\"` | string: binary string (byte `n` is `data.charCodeAt(n)`)        |\n| `\"buffer\"` | nodejs Buffer                                                   |\n| `\"file\"`   | string: path of file that will be created (nodejs only)         |\n| (default)  | buffer if available, array of 8-bit unsigned int otherwise      |\n\n`opts.fileType` controls the output file type:\n\n| `fileType`         | output                  |\n|:-------------------|:------------------------|\n| `'cfb'` (default)  | CFB container           |\n| `'zip'`            | ZIP file                |\n| `'mad'`            | MIME aggregate document |\n\n`opts.compression` enables DEFLATE compression for ZIP file type.\n\n\n## Utility Functions\n\nThe utility functions are available in the `CFB.utils` object.  Functions that\naccept a `name` argument strictly deal with absolute file names:\n\n- `.cfb_new(?opts)` creates a new container object.\n- `.cfb_add(cfb, name, ?content, ?opts)` adds a new file to the `cfb`.\n  Set the option `{unsafe:true}` to skip existence checks (for bulk additions)\n- `.cfb_del(cfb, name)` deletes the specified file\n- `.cfb_mov(cfb, old_name, new_name)` moves the old file to new path and name\n- `.use_zlib(require(\"zlib\"))` loads a nodejs `zlib` instance.\n\nBy default, the library uses a pure JS inflate/deflate implementation.  NodeJS\n`zlib.InflateRaw` exposes the number of bytes read in versions after `8.11.0`.\nIf a supplied `zlib` does not support the required features, a warning will be\ndisplayed in the console and the pure JS fallback will be used.\n\n\n## Container Object Description\n\nThe objects returned by `parse` and `read` have the following properties:\n\n- `.FullPaths` is an array of the names of all of the streams (files) and\n  storages (directories) in the container.  The paths are properly prefixed from\n  the root entry (so the entries are unique)\n\n- `.FileIndex` is an array, in the same order as `.FullPaths`, whose values are\n  objects following the schema:\n\n```typescript\ninterface CFBEntry {\n  name: string; /** Case-sensitive internal name */\n  type: number; /** 1 = dir, 2 = file, 5 = root ; see [MS-CFB] 2.6.1 */\n  content: Buffer | number[] | Uint8Array; /** Raw Content */\n  ct?: Date; /** Creation Time */\n  mt?: Date; /** Modification Time */\n  ctype?: String; /** Content-Type (for MAD) */\n}\n```\n\n\n## License\n\nPlease consult the attached LICENSE file for details.  All rights not explicitly\ngranted by the Apache 2.0 License are reserved by the Original Author.\n\n\n## References\n\n - `MS-CFB`: Compound File Binary File Format\n - ZIP `APPNOTE.TXT`: .ZIP File Format Specification\n - RFC1951: https://www.ietf.org/rfc/rfc1951.txt\n - RFC2045: https://www.ietf.org/rfc/rfc2045.txt\n - RFC2557: https://www.ietf.org/rfc/rfc2557.txt\n\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSheetJS%2Fjs-cfb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSheetJS%2Fjs-cfb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSheetJS%2Fjs-cfb/lists"}