Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsonArray _to_excel #11

Open
deligent-ant opened this issue Jun 17, 2018 · 1 comment
Open

jsonArray _to_excel #11

deligent-ant opened this issue Jun 17, 2018 · 1 comment

Comments

@deligent-ant
Copy link
Contributor

deligent-ant commented Jun 17, 2018

个人插件 写一些平时自己用到的一些组件,主要基于 vue

具体插件

  • jsonArray 导出到excel
    import FileSaver from 'file-saver'
    import XLSX from 'xlsx'
  props: {
  params: {
    type: Object,
    default: () => {} //{jsonData:[],keyMap:{name:'名字'}}
  }
},

这个组件输入,一个是待转化的对象数组,字段会是表格的表头,然后 keyMap,传入可将对应的英文字段 在 excel 用中文展示,以及表头的顺序。如果没传入 keyMap,默认使用 Object.key(jsonData)

对应的的组件链接outportXlsx

附上

  • 从excel导入至jsonArray
    对应的的组件链接ImportXLSX
 props: {
    onImport: {
      type: Function,
      default: () => {}
    }
  },
  • 这个函数的第一个参数是excel数据,[sheet1,sheet2,...],所以第一个参数arrays 对应的arrays[0],才是第一个工作表对应的数据。
@catee
Copy link
Contributor

catee commented Jun 20, 2018

能否 抽象出个 操作 excel 的 vue 组件?支持 导入/导出 功能 [手动看好你]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants