关于vue开发中读取excel 的问题

在开发中需要读取excel的 然后使用了xlsx
表格是这样的
关于vue开发中读取excel 的问题
现在的问题是把数据读取出来 然后组成数组 格式是这种
关于vue开发中读取excel 的问题
data存放的是除了前面两个以外单元格A3-A30的数据

关于vue开发中读取excel 的问题

现在需要怎么获取到单元格A3-A30的数据 然后填充到data里

感谢!

最佳答案
// 假设读取到的数据
const dataList = [
  {姓名: 'xxx1', 手机: 'xxxxxx1', 基本工资: 1000, 绩效: 5000},
  {姓名: 'xxx2', 手机: 'xxxxxx2', 基本工资: 2000, 绩效: 6000},
  {姓名: 'xxx3', 手机: 'xxxxxx3', 基本工资: 3000, 绩效: 7000},
  {姓名: 'xxx4', 手机: 'xxxxxx4', 基本工资: 4000, 绩效: 8000}
]
// 处理数据
const result = dataList.map((item, index) => {
   const cellData = Object.entries(item).map(([key, value]) => {
    return {[key]: value}
  })
  const [A1, A2, ...otherCell] = cellData
  return {
    userName: A1.姓名,
    手机: A2.手机,
    data: Object.assign({}, ...otherCell)
  }
})
console.log(result)

可以复制到浏览器控制台运行~
看看是不是这个意思,是否有帮助~~

2年前 评论
GUITAR (楼主) 2年前
讨论数量: 3

这种定制需求,就直接写?

2年前 评论
// 假设读取到的数据
const dataList = [
  {姓名: 'xxx1', 手机: 'xxxxxx1', 基本工资: 1000, 绩效: 5000},
  {姓名: 'xxx2', 手机: 'xxxxxx2', 基本工资: 2000, 绩效: 6000},
  {姓名: 'xxx3', 手机: 'xxxxxx3', 基本工资: 3000, 绩效: 7000},
  {姓名: 'xxx4', 手机: 'xxxxxx4', 基本工资: 4000, 绩效: 8000}
]
// 处理数据
const result = dataList.map((item, index) => {
   const cellData = Object.entries(item).map(([key, value]) => {
    return {[key]: value}
  })
  const [A1, A2, ...otherCell] = cellData
  return {
    userName: A1.姓名,
    手机: A2.手机,
    data: Object.assign({}, ...otherCell)
  }
})
console.log(result)

可以复制到浏览器控制台运行~
看看是不是这个意思,是否有帮助~~

2年前 评论
GUITAR (楼主) 2年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!