迟到的教程:【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
 
已邀请:

李东彬

赞同来自:

致命错误: Class 'plugins\Excel\admin\Excel' not found
使用插件出现这样的错误

微冷的夏季 - 入门级小白PHPer

赞同来自:

怎么获取插入的id.对数据进行2次操作.比如,我更新一下分类id.

龙猫

赞同来自:

图片怎么导入呢?

cc110110

赞同来自:

提示找不到文件是怎么错误

etuos - 80后IT

赞同来自:

数据去重检查,检查的是非同一批次导入的数据,同一批次导入的数据没有进行检查。

要回复问题请先登录注册