Giter VIP home page Giter VIP logo

form-render-excel's Introduction

form-render-excel

安装

npm i form-render-excel --save

使用

import React, { useState } from 'react';
import 'antd/dist/antd.css';
import FR from 'form-render/lib/antd';
import HOC from 'form-render-excel';
import schema from './schema.json';

// 把原来的 FormRender 包一下
const NFR = HOC(FR);

export default () => {
  const [formData, setFormData] = useState({});

  // 当成正常的 FormRender 来使用
  return <NFR schema={schema} formData={formData} onChange={setFormData} />;
};

在 schema 中对应的数组的 ui:options 里使用 useExcel 注明需要使用 excel 功能:

{
  "type": "object",
  "properties": {
    "arrDemo": {
      "title": "搬砖统计",
      "type": "array",
      "ui:options": {
        "useExcel": true
      },
      "items": {
        "type": "object",
        "properties": {
          "year": {
            "title": "年份",
            "type": "number"
          },
          "value": {
            "title": "搬砖量",
            "type": "number"
          }
        }
      }
    }
  }
}

功能

支持复杂的数组多层套对象的导入导出,可以 clone 下代码,跑起来试玩一下~

导出功能

导入功能

form-render-excel's People

Contributors

mzl980425 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.