# excel-creator-test

> NPM Package for creating Excel with subtitles from nested objects

Latest version **2.0.0** (published 2022-10-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install excel-creator-test
pnpm add excel-creator-test
yarn add excel-creator-test
bun add excel-creator-test
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-10-31 |
| First published | 2022-10-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 71 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | beni muler |
| Maintainers | benimuler |
| Keywords | excel |

## Links

- npm: https://www.npmjs.com/package/excel-creator-test
- Repository: https://gitlab.com/yesodot/selenium/blueomek/common/blue-omek-xlsx-creator
- Homepage: https://gitlab.com/yesodot/selenium/blueomek/common/blue-omek-xlsx-creator#readme
- Issues: https://gitlab.com/yesodot/selenium/blueomek/common/blue-omek-xlsx-creator/issues
- npm.io page: https://npm.io/package/excel-creator-test

## Dependencies (4)

- [xlsx](https://npm.io/package/xlsx.md) ^0.17.4
- [bluebird](https://npm.io/package/bluebird.md) ^3.7.2
- [python-shell](https://npm.io/package/python-shell.md) ^3.0.1
- [xlsx-populate](https://npm.io/package/xlsx-populate.md) ^1.21.0

## Recent versions

- 2.0.0 (latest) — 2022-10-31

## README

[![npm version](https://badge.fury.io/js/angular2-expandable-list.svg)](https://badge.fury.io/js/angular2-expandable-list)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# excel-creator

NPM Package for creating Excel with subtitles from nested objects.

## Prerequisites

This project requires NodeJS (version 8 or later) and NPM.
[Node](http://nodejs.org/) and [NPM](https://npmjs.org/) are really easy to install.
To make sure you have them available on your machine,
try running the following command.

```sh
$ npm -v && node -v
6.4.1
v8.16.0
```
First make sure you are able to run python3 (Mac/Linux) or python (Windows) from the terminal. If you are not then you might need to add it to the PATH. If you want to use a version of python not in the PATH you should specify pythonPath.

## DockerFile requirements
# Install git for the @types/xlsx-populate dependency
RUN apk add --no-cache git

# Download python and pip and udpate pip
RUN apk add --no-cache python3 py3-pip && \
    pip3 install --no-cache-dir --upgrade pip

# Download required libraries
RUN python3 -m pip install --no-cache-dir json_excel_converter && \
    python3 -m pip install --no-cache-dir xlsxwriter
## Table of contents

- [Project Name](#excel-creator)
  - [Prerequisites](#prerequisites)
  - [DockerFile requirements](#DockerFile-requirements)
  - [Table of contents](#table-of-contents)
  - [Getting Started](#getting-started)
  - [Installation](#installation)
  - [Usage](#usage)
    - [createExcel](#createExcel)
      - [variables](#variables)
      - [merges](#merges)
  - [Example](#Example)
  - [Credits](#credits)
  - [Authors](#authors)
  - [License](#license)

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

## Installation

**BEFORE YOU INSTALL:** please read the [prerequisites](#prerequisites)

To install and set up the library, run:

```sh
$ npm install -S excel-creator
```

Or if you prefer using Yarn:

```sh
$ yarn add --dev excel-creator
```

## Usage
### createExcel

```js
createExcel(path: string, workSheets: UserData[]): Promise<NodeJS.ReadableStream>
```

```js
export interface ExcelFileStruct {
  fileName?: string;
  workSheets: UserData[];
}

type VerticalAlignment = 'top' | 'middle' | 'bottom';
type HorizontalAlignment = 'left' | 'center' | 'right';

export interface IExcelOptions {
  verticalAlignment?: VerticalAlignment;
  horizontalAlignment?: HorizontalAlignment;
  boldHeaders?: boolean;
  headersBottomBorder?: boolean;
}

export interface UserData {
  workSheetName: string;
  translation?: { [key: string]: string };
  data?: Record<string, any>;
}

```


#### Variables

 * `path`

  

| Type | 
| --- | 
| string | 

The path to save the file

 * `worksheets`



| Type | 
| --- | 
| UserData | 

The array containing the information aboute the sheets

#### Worksheets properties

`workSheetName`

  

| Type | Default value |
| --- | --- |
| string| 'sheet' |

  

The name of the sheet

  

`data`

  

| Type | Default value |
| --- | --- |
| Record<string, any> | 'center' |

  

The actual sheets text.
Keys for headers and values for the values.
If you want just one value the syntax is:
```jsx
{ key: 'value' }
```

If you want just many values the syntax is:
```jsx
{ key: ['value1','value2'] }
```

###merges
####horizontal merge:
If you want subtitle for specific key the syntax is:
```jsx
{ mainTitleName: { subTitleName: 'value'} }
```
You can add how many nested subtitles that you want.
For better understanding look at the example.

####vertical merge:
In order to achieve vertical merges you have to specify the key word **#merge{number}#** where the
number is the number of cells you want to merge. The next object propery will be the only thing present
in the merged cell. For example, if you have an array like so 
```jsx
    {title:['#merge3#', 'a', 'f' ]}
```
The resulting excel will look as follows:
![example excel](https://i.imgur.com/D5gX9Xt.png)

`translation`

  

| Type | Default value |
| --- | --- |
| translation: { beni:  'beni2', old:  'veryOld' }/undefined | undefined |

  

Translate any key or value to another text.


`options`

Contain the next properties: 


`verticalAlignment`

| Type | Default value |
| --- | --- |
| 'top'/ 'middle' / 'bottom' | 'top'   |

The vertical alignment of the text

`horizontalAlignment`

| Type | Default value |
| --- | --- |
| 'left'/ 'center' / 'right' | 'center'   |

The horizontal alignment of the text

`boldHeaders`

| Type | Default value |
| --- | --- |
| boolean | false   |

Define if the headers are bold

`headersBottomBorder`

| Type | Default value |
| --- | --- |
| boolean | false   |

Define if there is a line under the headers headers are bold
  

* pythonPath 

| Type | Default value |
| --- | --- |
| string / null | null   |

If you want to use a version of python not in the PATH you should specify pythonPath.


#### Example:

```jsx
import { createExcel } from  'excel-creator';
import  path  from  'path';

const  main = async () => {
  await  createExcel(
    path.resolve(__dirname, '../index.xlsx'),

    [
      {
        data: { names: { boys: { young: ['beni', 'itay'], old:  'mati' }, girls: ['a', 'c', 'e'] } },
        workSheetName:  'greatShit',
        translation: { beni:  'beni2', old:  'veryOld' },
        options: { verticalAlignment:  'top', horizontalAlignment:'center', boldHeaders:  true, headersBottomBorder:  true },
      },
    ],
  );
};

  

main();
```

result:

![example excel](https://i.imgur.com/xB2Igr7.png)




## Credits

Binyamin Muller,
Itay Tovim

## Authors

* **Binyamin Muller** - *Initial work* 
* **Itay Tovim** - *Initial work* 

## License

[MIT License](https://andreasonny.mit-license.org/2019) © Andrea SonnY

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