更新记录
1.0.1(2026-01-25) 下载此版本
修改说明
1.0.0(2026-01-25) 下载此版本
解析 Excel(H5+ Android),在线、本地excel文件
平台兼容性
uni-app(3.6.15)
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|
| √ | √ | - | - | √ | √ | √ | - | - |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| - | - | - | - | - | - | - | - | - | - | - | - |
lu-parse-excel
解析 Excel(H5+ Android)
安装xlsx
```
pnpm add xlsx
```
使用方法
默认解析的表头作为结果的key
<template>
<view class="container">
<button type="primary" @click="start">解析 Excel(H5+ Android)</button>
<view v-if="list.length" class="">
{{ list }}
</view>
</view>
</template>
<script>
import { parseExcelFile } from '@/uni_modules/lu-parse-excel/js_sdk/excelUtils.js';
export default {
data() {
return {
// 在线链接,需要下载到本地,替换自己路径
excelUrl:
'https://ethan009.s3.bitiful.net/2026-0-0-11-IMqikTPNFk---.xlsx?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=dYC24uxJ31uhZwJR8qYoc7fg%2F20260125%2Fcn-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260125T033524Z&X-Amz-Expires=1800&X-Amz-SignedHeaders=host&no-wait=5&response-content-disposition=attachment&x-bitiful-limit-rate=5242880&x-bitiful-max-requests=2&x-id=GetObject&X-Amz-Signature=f2270777a83964af070eb7d2c1ad8f675e7be80408a54e84ff0d6917c58d3913',
// 本地文件路径,需要替换成你自己的文件路径,跳过uni.downloadFile步骤
tempFilePath: '',
list: []
};
},
methods: {
async start() {
console.log('[STEP 0] 点击按钮');
uni.showLoading({ title: '解析中...' });
try {
// 下载文件
const res = await new Promise((resolve, reject) => {
uni.downloadFile({
url: this.excelUrl,
success: resolve,
fail: reject
});
});
this.tempFilePath = res.tempFilePath;
console.log('[STEP 1] 下载成功,路径:', this.tempFilePath);
// 定义字段映射
const fieldMap = {
姓名: 'name',
年龄: 'age',
性别: 'sex'
};
// 调用工具函数解析
const mappedData = await parseExcelFile(this.tempFilePath, fieldMap);
console.log('[STEP 7] 最终数据:', mappedData);
// ✅ 这里可以处理 mappedData,比如
this.list = mappedData;
uni.showToast({
title: '解析成功',
icon: 'success'
});
} catch (err) {
console.error('[ERROR] 流程出错:', err);
uni.showToast({ title: err.message, icon: 'none' });
} finally {
uni.hideLoading();
}
}
}
};
</script>
<style>
.container {
padding: 40rpx;
}
</style>
字段映射
key 表头名称,value 对应的字段名称
const fieldMap = {
姓名: 'name',
年龄: 'age',
性别: 'sex',
手机号: 'phone',
邮箱: 'email',
地址: 'address',
备注: 'remark',
};
注意事项
- 在线文件需要先下载到本地,再进行解析
- 解析的文件需要是xlsx格式

收藏人数:
下载插件并导入HBuilderX
下载插件ZIP
赞赏(0)
下载 367
赞赏 1
下载 13647467
赞赏 1851
赞赏
京公网安备:11010802035340号