迟到的教程:【Excel 插件】 导入 Excel 教程
原文:
miaoqiang.name/archives/dolphinphp-excel-plugins.html
代码示例:
public function index()
{
// 提交数据
if ($this->request->isPost()) {
// 接收附件 ID
$excel_file = $this->request->post('excel');
// 获取附件 ID 完整路径
$full_path = getcwd() . get_file_path($excel_file);
// 只导入的字段列表
$fields = [
'name' => '姓名',
'last_login_time' => '最后登录时间',
'last_login_ip' => '最后登陆IP'
];
// 调用插件('插件',[路径,导入表名,字段限制,类型,条件,重复数据检测字段])
$import = plugin_action('Excel/Excel/import', [$full_path, 'vip_test', $fields, $type = 0, $where = null, $main_field = 'name']);
// 失败或无数据导入
if ($import['error']){
$this->error($import['message']);
}
// 导入成功
$this->success($import['message']);
}
// 创建演示用表单
return ZBuilder::make('form')
->setPageTitle('导入Excel')
->addFormItems([ // 添加上传 Excel
['file', 'excel', '上传文件'],
])
->fetch();
}
导出Excel教程:http://bbs.dolphinphp.com/?/article/16
没有找到相关结果
已邀请:
5 个回复
李东彬
赞同来自:
使用插件出现这样的错误
微冷的夏季 - 入门级小白PHPer
赞同来自:
龙猫
赞同来自:
cc110110
赞同来自:
etuos - 80后IT
赞同来自: