본문으로 건너뛰기

엑셀 다운로드 시 자체상품코드 텍스트 서식 적용

PHP 8 · GODO25
변경 파일 수: 3개
변경 파일 목록
총 3개
변경 파일 코드
추가삭제
Component/Excel/ExcelDataConvert.php+2-2
변경 전ExcelDataConvert.php
$this->excelBody[] = '<td>' . ($key+1) . '</td>' . chr(10);
$this->excelBody[] = '<td class="xl24">' . $resultValue['orderNo'] . '</td>' . chr(10);
$this->excelBody[] = '<td>' . $resultValue['orderGroup'] . '</td>' . chr(10);
$this->excelBody[] = '<td>' . $resultValue['goodsCd'] . '</td>' . chr(10);
$this->excelBody[] = '<td>' . $resultValue['optionCode'] . '</td>' . chr(10);
$this->excelBody[] = '<td>' . $resultValue['result'] . '</td>' . chr(10);
$this->excelBody[] = '<td>' . $resultValue['message'] . '</td>' . chr(10);
$this->excelBody[] = '</tr>' . chr(10);
 
변경 후ExcelDataConvert.php
$this->excelBody[] = '<td>' . ($key+1) . '</td>' . chr(10);
$this->excelBody[] = '<td class="xl24">' . $resultValue['orderNo'] . '</td>' . chr(10);
$this->excelBody[] = '<td>' . $resultValue['orderGroup'] . '</td>' . chr(10);
$this->excelBody[] = '<td class="xl24">' . $resultValue['goodsCd'] . '</td>' . chr(10);
$this->excelBody[] = '<td class="xl24">' . $resultValue['optionCode'] . '</td>' . chr(10);
$this->excelBody[] = '<td>' . $resultValue['result'] . '</td>' . chr(10);
$this->excelBody[] = '<td>' . $resultValue['message'] . '</td>' . chr(10);
$this->excelBody[] = '</tr>' . chr(10);
 
Component/Excel/ExcelRequest.php+7-2
변경 전ExcelRequest.php
$tmpData[] = "<td></td>";
}
 
 
 
 
break;
default :
if ($excelFieldName[$excelValue]['type'] == 'mileage' && $val[$excelValue] != '') {
}
$tmpData[] = "<td>" . $settleKind . "</td>";
break;
// 숫자 처리 - 주문 번호 및 우편번호(5자리) 숫자에 대한 처리
 
case 'orderNo':
case 'apiOrderNo':
case 'apiOrderGoodsNo':
case 'settleKind':
$tmpData[] = "<td>" . $orderDelete->printSettleKind($val[$excelValue]) . "</td>";
break;
// 숫자 처리 - 주문 번호 및 우편번호(5자리) 숫자에 대한 처리
 
case 'orderNo':
case 'apiOrderNo':
case 'apiOrderGoodsNo':
 
변경 후ExcelRequest.php
$tmpData[] = "<td></td>";
}
 
break;
case 'goodsCd':
$tmpData[] = "<td class=\"xl24\">" . $val[$excelValue] . "</td>";
break;
default :
if ($excelFieldName[$excelValue]['type'] == 'mileage' && $val[$excelValue] != '') {
}
$tmpData[] = "<td>" . $settleKind . "</td>";
break;
// 숫자 처리 - 주문 번호, 우편번호(5자리), 자체상품코드 등 숫자로 인식되면 안 되는 값
case 'goodsCd':
case 'orderNo':
case 'apiOrderNo':
case 'apiOrderGoodsNo':
case 'settleKind':
$tmpData[] = "<td>" . $orderDelete->printSettleKind($val[$excelValue]) . "</td>";
break;
// 숫자 처리 - 주문 번호, 우편번호(5자리), 자체상품코드 등 숫자로 인식되면 안 되는 값
case 'goodsCd':
case 'orderNo':
case 'apiOrderNo':
case 'apiOrderGoodsNo':
 
Component/Excel/ExcelSample.php+9
변경 전ExcelSample.php
use Framework\Utility\ImageUtils;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Helper\Html;
 
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
 
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
 
$this->setHeaderCellStyle($headerLastRow);
$this->setAllCellStyle();
 
 
 
 
 
 
 
 
return $this->spreadsheet;
}
 
 
변경 후ExcelSample.php
use Framework\Utility\ImageUtils;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Helper\Html;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
 
$this->setHeaderCellStyle($headerLastRow);
$this->setAllCellStyle();
 
// 샘플에 새로 입력하는 자체상품코드의 앞자리 0 이 잘리지 않도록 열 서식을 텍스트로 지정한다
$goodsCdIndex = array_search('goodsCd', array_column($excelGoodsField, 'dbKey'), true);
if ($goodsCdIndex !== false) {
$goodsCdColumn = Coordinate::stringFromColumnIndex($goodsCdIndex + 1);
$this->worksheet->getStyle("{$goodsCdColumn}:{$goodsCdColumn}")->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
}
 
return $this->spreadsheet;
}