# @lupa/excel

> Use Excel data inside React

Latest version **0.3.0** (published 2022-03-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @lupa/excel
pnpm add @lupa/excel
yarn add @lupa/excel
bun add @lupa/excel
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2022-03-07 |
| First published | 2020-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 151.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Tyler Cosgrove |
| Maintainers | vivalldi |
| Keywords | react, dataset, data, excel |

## Links

- npm: https://www.npmjs.com/package/@lupa/excel
- Repository: https://github.com/mondobrain/lupa
- Homepage: https://github.com/mondobrain/lupa#readme
- Issues: https://github.com/mondobrain/lupa/issues
- npm.io page: https://npm.io/package/@lupa/excel

## Dependencies (2)

- [@lupa/lupa](https://npm.io/package/@lupa/lupa.md) ^0.3.0
- [@types/office-js](https://npm.io/package/@types/office-js.md) ^1.0.117

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2022-03-07
- 0.2.7 — 2021-02-01
- 0.2.6 — 2021-01-19
- 0.2.5 — 2021-01-19
- 0.2.4 — 2021-01-18
- 0.2.3 — 2021-01-18
- 0.2.2 — 2020-10-08
- 0.2.1 — 2020-07-22
- 0.2.0 — 2020-07-17
- 0.1.0 — 2020-07-17

## README

<h3 align="center">
  Lupa Excel
</h3>

<p align="center">
  Use Excel data inside <a href="https://facebook.github.io/react">React</a>
</p>

<p align="center">
  <a href="https://www.npmjs.com/package/@lupa/excel"><img src="https://img.shields.io/npm/v/@lupa/excel?style=flat-square"></a>
  <a href="https://www.npmjs.com/package/@lupa/excel"><img src="https://img.shields.io/npm/dm/@lupa/excel?style=flat-square"></a>
  <a href="https://bundlephobia.com/result?p=@lupa/excel"><img src="https://img.shields.io/bundlephobia/minzip/@lupa/excel?style=flat-square"></a>
</p>

## Installation

`Lupa` is on NPM so install using your preferred JS package manager.

```bash
yarn add @lupa/excel @lupa/lupa
npm install @lupa/excel @lupa/lupa
```

## Usage

In order for the `<ExcelDataset>` component to load, you need to have [Office.js][1] loaded. The easiest way to load [Office.js][1] is to include the following script tag in your page header

```html
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
```

With [Office.js][1] loaded, wrap the top level of your React app in the `<ExcelDataset>` component;

```jsx
import { ExcelDataset } from '@lupa/excel';


export default function App() {
  return (
    <ExcelDataset>
      <div>The rest of my app</div>
      <SomeChild />
    </ExcelDataset>
  )
}

```

Now in any of the components underneath `<ExcelDataset>` you can use the various hooks from `@lupa/lupa`;

```jsx
import React from 'react';
import { useData, useFeatures, useShape } from '@lupa/lupa';

export default function LupaInfo() {
  const data = useData();
  const features = useFeatures();
  const shape = useShape();

  const onClick = React.useCallback(async () => {
    // We know that `data` is an async function because we're inside <ExcelDataset>
    // Generic components should use `dataIsAsyncMethod` or `dataIsRowArray` from '@lupa/lupa'
    const d = await data();
    console.log(d);
  }, [data]);

  return (
    <div>
      <h2>Data</h2>
      <div>
        <h4>Shape</h4>
        {shape}
      </div>
      <div>
        <h4>Features</h4>
        {features.map(f => <div key={f.key}>{key}</div>)}
      </div>
      <div>
        <h4>Data</h4>
        <button onClick={onClick}>Show data</button>
      </div>
    </div>
  )
}
```

[//]: # (Link References)
[1]: https://docs.microsoft.com/en-us/office/dev/add-ins/develop/understanding-the-javascript-api-for-office "OfficeJS"

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