首页
文章分类
源码资源
技术教程
程序软件
文创娱乐
公告通知
其他页面
友情链接
闲聊灌水
关于我们
发布
登录
注册
找回密码
首页
文章分类
源码资源
技术教程
程序软件
文创娱乐
公告通知
其他页面
友情链接
闲聊灌水
关于我们
登录
注册
找回密码
php
共7篇
php
排序
发布
更新
浏览
点赞
评论
人人商城处理导入Excel和导入Excel的方法
人人商城处理导入Excel和导入Excel的方法 导入 前端 <form id="importform" class="form-horizontal form" action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="typeid" value="{$item['id']}"/> <div class='form-group'> <div class="form-group"> <label class="col-lg control-label must">EXCEL</label> <div class="col-sm-5 goodsname" style="padding-right:0;" > <input type="file" name="excelfile" class="form-control" /> <!-- <span class="help-block">如果遇到数据重复则将进行数据更新</span>--> </div> </div> </div> <div class='form-group'> <div class="col-sm-12"> <div class="modal-footer" style="text-align: left"> <!-- {ifp 'order.batchsend.main'}--> <button type="submit" class="btn btn-primary" name="cancelsend" value="yes">确认导入</button> <!-- {/if}--> <!-- {ifp 'order.batchsend.import'}--> <!-- <a class="btn btn-primary" href="{php echo webUrl('order/batchsend/import')}" style="margin-right: 10px;" ><i class="fa fa-download" title=""></i> 下载Excel模板文件</a>--> <!-- {/if}--> </div> </div> </div> <!--</div>--> </form>后端 if ($_W['ispost']) { // 读取Excel $rows = m('excel')->import('excelfile'); $num = count($rows); $time = time(); $i = 0; $err_array = array(); unset($rows[0]); // 循环插入数据 foreach ($rows as $k=>$v){ var_dump($v); $createData['uniacid'] = $_W['uniacid']; $createData['name'] = $v[1]; $createData['work_number'] = $v[2]; $createData['serial_number'] = $v[0]; $createData['superior_id'] = 0; pdo_insert('ewei_shop_team', $createData); $superior_id = pdo_insertid(); $createData['uniacid'] = $_W['uniacid']; $createData['name'] = $v[3]; $createData['work_number'] = $v[4]; $createData['serial_number'] = $v[0]; $createData['superior_id'] = $superior_id; pdo_insert('ewei_shop_team', $createData); $createData['uniacid'] = $_W['uniacid']; $createData['name'] = $v[5]; $createData['work_number'] = $v[6]; $createData['serial_number'] = $v[0]; $createData['superior_id'] = $superior_id; pdo_insert('ewei_shop_team', $createData); } }导出 // 导出excel if ($_GPC['export'] == 1) { ca('statistics.goods.export'); $list[] = array('data' => '商品总计', 'count' => $total); foreach ($list as &$row) { $row['createtime'] = date('Y-m-d H:i', $row['createtime']); } unset($row); // $list是每一行的数据 m('excel')->export($list, array( 'title' => '商品销售报告-' . date('Y-m-d-H-i', time()), 'columns' => array( array('title' => '订单号', 'field' => 'ordersn', 'width' => 24), array('title' => '商品名称', 'field' => 'title', 'width' => 48), array('title' => '规格名称', 'field' => 'optiontitle', 'width' => 24), array('title' => '商品编号', 'field' => 'goodssn', 'width' => 12), array('title' => '数量', 'field' => 'total', 'width' => 12), array('title' => '价格', 'field' => 'price', 'width' => 12), array('title' => '成交时间', 'field' => 'createtime', 'width' => 24) ) )); plog('statistics.goods.export', '导出商品销售明细'); }
韩昊杰
4年前
0
0
0
如何配置php.ini才能让PHP性能最大优化
人人商城处理导入Excel和导入Excel的方法 导入 前端 <form id="importform" class="form-horizontal form" action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="typeid" value="{$item['id']}"/> <div class='form-group'> <div class="form-group"> <label class="col-lg control-label must">EXCEL</label> <div class="col-sm-5 goodsname" style="padding-right:0;" > <input type="file" name="excelfile" class="form-control" /> <!-- <span class="help-block">如果遇到数据重复则将进行数据更新</span>--> </div> </div> </div> <div class='form-group'> <div class="col-sm-12"> <div class="modal-footer" style="text-align: left"> <!-- {ifp 'order.batchsend.main'}--> <button type="submit" class="btn btn-primary" name="cancelsend" value="yes">确认导入</button> <!-- {/if}--> <!-- {ifp 'order.batchsend.import'}--> <!-- <a class="btn btn-primary" href="{php echo webUrl('order/batchsend/import')}" style="margin-right: 10px;" ><i class="fa fa-download" title=""></i> 下载Excel模板文件</a>--> <!-- {/if}--> </div> </div> </div> <!--</div>--> </form>后端 if ($_W['ispost']) { // 读取Excel $rows = m('excel')->import('excelfile'); $num = count($rows); $time = time(); $i = 0; $err_array = array(); unset($rows[0]); // 循环插入数据 foreach ($rows as $k=>$v){ var_dump($v); $createData['uniacid'] = $_W['uniacid']; $createData['name'] = $v[1]; $createData['work_number'] = $v[2]; $createData['serial_number'] = $v[0]; $createData['superior_id'] = 0; pdo_insert('ewei_shop_team', $createData); $superior_id = pdo_insertid(); $createData['uniacid'] = $_W['uniacid']; $createData['name'] = $v[3]; $createData['work_number'] = $v[4]; $createData['serial_number'] = $v[0]; $createData['superior_id'] = $superior_id; pdo_insert('ewei_shop_team', $createData); $createData['uniacid'] = $_W['uniacid']; $createData['name'] = $v[5]; $createData['work_number'] = $v[6]; $createData['serial_number'] = $v[0]; $createData['superior_id'] = $superior_id; pdo_insert('ewei_shop_team', $createData); } }导出 // 导出excel if ($_GPC['export'] == 1) { ca('statistics.goods.export'); $list[] = array('data' => '商品总计', 'count' => $total); foreach ($list as &$row) { $row['createtime'] = date('Y-m-d H:i', $row['createtime']); } unset($row); // $list是每一行的数据 m('excel')->export($list, array( 'title' => '商品销售报告-' . date('Y-m-d-H-i', time()), 'columns' => array( array('title' => '订单号', 'field' => 'ordersn', 'width' => 24), array('title' => '商品名称', 'field' => 'title', 'width' => 48), array('title' => '规格名称', 'field' => 'optiontitle', 'width' => 24), array('title' => '商品编号', 'field' => 'goodssn', 'width' => 12), array('title' => '数量', 'field' => 'total', 'width' => 12), array('title' => '价格', 'field' => 'price', 'width' => 12), array('title' => '成交时间', 'field' => 'createtime', 'width' => 24) ) )); plog('statistics.goods.export', '导出商品销售明细'); }
韩昊杰
4年前
0
0
0
上一页
1
2
在手机上浏览此页面
退出登录
您好!
确认要退出当前登录吗?
取消
确认退出
我是韩昊杰
一个一直在用心写代码的程序员
必须认同
认同吧