# excel-export

> Simple data set export to Excel xlsx file

Latest version **0.5.1** (published 2016-02-09) · BSD license · 0 weekly downloads

## Install

```sh
npm install excel-export
pnpm add excel-export
yarn add excel-export
bun add excel-export
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2016-02-09 |
| First published | 2013-04-03 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 493 |
| Author | Ber-Lin Lai |
| Maintainers | functionscope |
| Keywords | Excel, xlsx |

## Links

- npm: https://www.npmjs.com/package/excel-export
- Repository: https://github.com/functionscope/Node-Excel-Export
- Issues: https://github.com/functionscope/Node-Excel-Export/issues
- npm.io page: https://npm.io/package/excel-export

## Dependencies (2)

- [node-zip](https://npm.io/package/node-zip.md) 1.x
- [collections](https://npm.io/package/collections.md) ^3.0.0

## Recent versions

- 0.5.1 (latest) — 2016-02-09
- 0.4.1 — 2014-11-02
- 0.3.11 — 2014-01-23
- 0.3.10 — 2014-01-09
- 0.3.9 — 2013-12-04
- 0.3.7 — 2013-10-18
- 0.3.1 — 2013-09-27
- 0.3.0 — 2013-09-10
- 0.2.1 — 2013-06-12
- 0.1.2 — 2013-04-04
- 0.1.1 — 2013-04-04
- 0.1.0 — 2013-04-03

## README

# excel-export #

A simple node.js module for exporting data set to Excel xlsx file.

## Using excel-export ##
Setup configs object before passing it into the execute method. If generating multiple sheets, configs object can be an array of worksheet configuration.  Or passing in a worksheet configuration to generate single worksheet xlsx file.   Within a worksheet configuration uses **name** attribute to specify worksheet name.  **cols** is an array for column definition.  Column definition should have caption and type properties while width property is not required.  The unit for width property is character.   **beforeCellWrite** callback is optional.  beforeCellWrite is invoked with row, cell data and option object (eOpt detail later) parameters.  The return value from beforeCellWrite is what get written into the cell.  Supported valid types are string, date, bool and number.  **rows** is the data to be exported. It is an Array of Array (row). Each row should be the same length as cols.  Styling is optional.  However, if you want to style your spreadsheet, a valid excel styles xml file is needed.  An easy way to get a styles xml file is to unzip an existing xlsx file which has the desired styles and copy out the styles.xml file. Use **stylesXmlFile** property of configuartion object to specify the relative path and file name of the xml file.  Google for "spreadsheetml style" to learn more detail on styling spreadsheet.  eOpt in beforeCellWrite callback contains rowNum for current row number. eOpt.styleIndex should be a valid zero based index from cellXfs tag of the selected styles xml file.  eOpt.cellType is default to the type value specified in column definition.  However, in some scenario you might want to change it for different format. 



    var express = require('express');
	var nodeExcel = require('excel-export');
	var app = express();

	app.get('/Excel', function(req, res){
	  	var conf ={};
		conf.stylesXmlFile = "styles.xml";
        conf.name = "mysheet";
	  	conf.cols = [{
			caption:'string',
            type:'string',
            beforeCellWrite:function(row, cellData){
				 return cellData.toUpperCase();
			},
            width:28.7109375
		},{
			caption:'date',
			type:'date',
			beforeCellWrite:function(){
				var originDate = new Date(Date.UTC(1899,11,30));
				return function(row, cellData, eOpt){
              		if (eOpt.rowNum%2){
                		eOpt.styleIndex = 1;
              		}  
              		else{
                		eOpt.styleIndex = 2;
              		}
                    if (cellData === null){
                      eOpt.cellType = 'string';
                      return 'N/A';
                    } else
                      return (cellData - originDate) / (24 * 60 * 60 * 1000);
				} 
			}()
		},{
			caption:'bool',
			type:'bool'
		},{
			caption:'number',
			 type:'number'				
	  	}];
	  	conf.rows = [
	 		['pi', new Date(Date.UTC(2013, 4, 1)), true, 3.14],
	 		["e", new Date(2012, 4, 1), false, 2.7182],
            ["M&M<>'", new Date(Date.UTC(2013, 6, 9)), false, 1.61803],
            ["null date", null, true, 1.414]  
	  	];
	  	var result = nodeExcel.execute(conf);
	  	res.setHeader('Content-Type', 'application/vnd.openxmlformats');
	  	res.setHeader("Content-Disposition", "attachment; filename=" + "Report.xlsx");
	  	res.end(result, 'binary');
	});

	app.listen(3000);
	console.log('Listening on port 3000');

---
_Source: https://npm.io/package/excel-export · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
