正在显示
1 个修改的文件
包含
6 行增加
和
3 行删除
@@ -312,6 +312,7 @@ class OrderController extends AdminBaseController | @@ -312,6 +312,7 @@ class OrderController extends AdminBaseController | ||
312 | //导出Excel | 312 | //导出Excel |
313 | $objPHPExcel = new \PHPExcel(); | 313 | $objPHPExcel = new \PHPExcel(); |
314 | 314 | ||
315 | + // 设置单元格宽度 | ||
315 | $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25); | 316 | $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25); |
316 | $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15); | 317 | $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15); |
317 | $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20); | 318 | $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20); |
@@ -400,6 +401,7 @@ class OrderController extends AdminBaseController | @@ -400,6 +401,7 @@ class OrderController extends AdminBaseController | ||
400 | 401 | ||
401 | $i = 2; | 402 | $i = 2; |
402 | 403 | ||
404 | + // 循环到导出数据 | ||
403 | foreach ($array as $v) { | 405 | foreach ($array as $v) { |
404 | $status = '未支付'; | 406 | $status = '未支付'; |
405 | if($v['status'] == 1) { | 407 | if($v['status'] == 1) { |
@@ -427,9 +429,11 @@ class OrderController extends AdminBaseController | @@ -427,9 +429,11 @@ class OrderController extends AdminBaseController | ||
427 | ]; | 429 | ]; |
428 | $vs['cell'] = Db::name('OrderOption')->where($where)->value('cell'); | 430 | $vs['cell'] = Db::name('OrderOption')->where($where)->value('cell'); |
429 | if($vs['type'] == 3) { | 431 | if($vs['type'] == 3) { |
432 | + // 纯数字字段转化为字符串格式,防止以科学计数法进行显示 | ||
430 | $objPHPExcel->setActiveSheetIndex(0) | 433 | $objPHPExcel->setActiveSheetIndex(0) |
431 | ->setCellValueExplicit($vs['cell'] . $i, $vs['user_choose'],\PHPExcel_Cell_DataType::TYPE_STRING); | 434 | ->setCellValueExplicit($vs['cell'] . $i, $vs['user_choose'],\PHPExcel_Cell_DataType::TYPE_STRING); |
432 | } elseif($vs['type'] == 8) { | 435 | } elseif($vs['type'] == 8) { |
436 | + // 导出图片格式,高度自适应 | ||
433 | if(!empty($vs['user_choose']) && file_exists('./upload/'.$vs['user_choose'])) { | 437 | if(!empty($vs['user_choose']) && file_exists('./upload/'.$vs['user_choose'])) { |
434 | $image = \think\Image::open('./upload/'.$vs['user_choose']); | 438 | $image = \think\Image::open('./upload/'.$vs['user_choose']); |
435 | // 返回图片的宽度 | 439 | // 返回图片的宽度 |
@@ -437,13 +441,12 @@ class OrderController extends AdminBaseController | @@ -437,13 +441,12 @@ class OrderController extends AdminBaseController | ||
437 | // 返回图片的高度 | 441 | // 返回图片的高度 |
438 | $height = $image->height(); | 442 | $height = $image->height(); |
439 | $default = $height/($width/100); | 443 | $default = $height/($width/100); |
440 | - //设置默认行高 | 444 | + //设置默认行高(通过图片缩放比例计算高度) |
441 | $objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight($default); | 445 | $objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight($default); |
442 | // 图片生成 | 446 | // 图片生成 |
443 | $objDrawing[$i] = new \PHPExcel_Worksheet_Drawing(); | 447 | $objDrawing[$i] = new \PHPExcel_Worksheet_Drawing(); |
444 | $objDrawing[$i]->setPath('./upload/'.$vs['user_choose']); | 448 | $objDrawing[$i]->setPath('./upload/'.$vs['user_choose']); |
445 | - // 设置宽度高度 | ||
446 | - $objDrawing[$i]->setHeight(100);//照片高度 | 449 | + // 设置宽度 |
447 | $objDrawing[$i]->setWidth(100); //照片宽度 | 450 | $objDrawing[$i]->setWidth(100); //照片宽度 |
448 | /*设置图片要插入的单元格*/ | 451 | /*设置图片要插入的单元格*/ |
449 | $objDrawing[$i]->setCoordinates($vs['cell'].$i); | 452 | $objDrawing[$i]->setCoordinates($vs['cell'].$i); |
-
请 注册 或 登录 后发表评论