# paste-from-excel

> Utility to allow pasting data intact from Excel into an HTML table

Latest version **1.0.5** (published 2021-06-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install paste-from-excel
pnpm add paste-from-excel
yarn add paste-from-excel
bun add paste-from-excel
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2021-06-30 |
| First published | 2020-05-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM |
| Node | ^12.20.0 |
| Dependencies | 0 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Francis Nepomuceno |
| Maintainers | n3ps |
| Keywords | paste, excel, table, html-table |

## Links

- npm: https://www.npmjs.com/package/paste-from-excel
- Repository: https://github.com/n3ps/paste-from-excel
- Homepage: https://github.com/n3ps/paste-from-excel#readme
- Issues: https://github.com/n3ps/paste-from-excel/issues
- npm.io page: https://npm.io/package/paste-from-excel

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2021-06-30
- 1.0.2 — 2021-06-29
- 1.0.1 — 2020-09-26
- 1.0.0 — 2020-05-03

## README

# paste-from-excel

Utility to allow pasting data intact from Excel (or any spreadsheet) into an HTML table with editable elements.

Requires a table with input elements or elements with contenteditable set to true.

## Install
```
npm install paste-from-excel
```

## Usage with libraries

### Material UI \<Table\>
```jsx
import parse from 'paste-from-excel'

const handlePaste = (e) => {
  return parse(e)
}

return (
  <TableContainer onPaste={ handlePaste }>
    <Table>
    /* TableCells with inputs */
    </Table>
  </TableContainer>
)
```

### React-Table
```jsx
import parse from 'paste-from-excel'

const handlePaste = (e) => {
  const options = {
    rowSelector: '.rt-tr-group',
    cellSelector: '.rt-td'
  }

  return parse(e, options)
}

return (
  <div onPaste={ handlePaste }>
    <ReactTable
      data={data}
      columns={columns}
    />
  </div>
)
```

## Usage with plain HTML
```html
<script src="https://cdn.jsdelivr.net/gh/n3ps/paste-from-excel/dist/paste-from-excel.min.js">

<table id="my-table">
  <tr>
    <td><input /></td>
    <td><input /></td>
  </tr>
</table>

<script>
  var myTable = document.querySelector('#my-table')
  myTable.addEventListener('paste', handlePaste)

  function handlePaste (e) {
    return window.PasteFromExcel(e)
  }
</script>
```

### Options

rowSelector
- Sets the selector to identify a "row". Default: `tr`

cellSelector
- Sets the selector to identify a "cell". Default: `td`

inputSelector
- Sets the selector for the element that act on the paste event, and to find suceeding "editable elements". Default: `input`

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