У меня есть проблемы с Laravel-Excel 3.1 после того, как я обновил версию Laravel и PHP-версию, я получил некоторое требование от Laravel для обновления Laravel-Excel. После этого у меня возникла проблема с Excel-Export, не поддерживаю новую версию (3.1), прежде чем я использую 2.1. Кто -нибудь может помочь обновить мой код в настоящее время выше? пожалуйста! И спасибо, ребята! < /p>
private function export_customer_invoice_report($customer_invs)
{
$data_array = array([
'Issue Date',
'Purchase Order Invoice',
'Bag ID',
'SKU',
'Color-Size',
'QTY',
'Sale Price',
'Additional Discount',
'Actual Sale Price',
'Delivery Fee',
'Customer Balance',
'Pre-Paid Amount',
'Supplier Actual Price',
'Remark']);
foreach ($customer_invs as $key => $value) {
$product_variants = Helper::get_pro_option_id($value->order_item_id);
$doubleSpace = strip_tags($product_variants);
$singleSpace_product_variants = str_replace("\n ", "", $doubleSpace);
$issue_date = Helper::dateTimeDisplay($value->created_at);
$additional_dis = $value->additional_discount_percent ? $value->additional_discount_percent : 0;
$sale_price_after_disc = ($value->unit_price * $value->count_item) - ((($value->unit_price * $value->count_item) * $value->discount_percent) / 100);
$total_sale_price_discount_addit = ($sale_price_after_disc * $value->additional_discount_percent) / 100;
$actual_sale_price = $sale_price_after_disc - $total_sale_price_discount_addit;
// check if supplier actual price is zero, take from supplier price instead
$supplier_actual_price = $value->supplier_order_actual_price > 0
? $value->supplier_order_actual_price
: $value->supplier_price;
$data_list = array(
$issue_date,
$value->invoice_id,
$value->bag_id,
OrderItem::getProductSKU($value->order_item_id),
$singleSpace_product_variants,
$value->count_item,
'$' . number_format($sale_price_after_disc, 2),
'%' . $additional_dis,
'$' . number_format($actual_sale_price, 2),
'$' . number_format($value->delivery_price, 2),
'$' . number_format($value->customer_balance, 2),
'$' . number_format($value->prepaid_amount, 2),
'¥' . number_format($supplier_actual_price, 2),
$value->note,
);
array_push($data_array, $data_list);
}
Excel::create('customer_invoice_report', function ($excel) use ($data_array) {
// Set the title
$excel->setTitle('no title');
$excel->setCreator('no no creator')->setCompany('no company');
$excel->setDescription('report file');
$excel->sheet('sheet1', function ($sheet) use ($data_array) {
$sheet->cells('A1:M1', function ($cells) {
$cells->setBackground('#e7e7e7');
$cells->setFontWeight('bold');
});
$row = 1;
$startRow = -1;
$previousKey = '';
foreach ($data_array as $index => $value) {
if ($startRow == -1) {
$startRow = $row;
$previousKey = $value[2];
}
$sheet->setCellValue('A' . $row, $value[0]);
$sheet->setCellValue('B' . $row, $value[1]);
$sheet->setCellValue('C' . $row, $value[2]);
$sheet->setCellValue('D' . $row, $value[3]);
$sheet->setCellValue('E' . $row, $value[4]);
$sheet->setCellValue('F' . $row, $value[5]);
$sheet->setCellValue('G' . $row, $value[6]);
$sheet->setCellValue('H' . $row, $value[7]);
$sheet->setCellValue('I' . $row, $value[8]);
$sheet->setCellValue('J' . $row, $value[9]);
$sheet->setCellValue('K' . $row, $value[10]);
$sheet->setCellValue('L' . $row, $value[11]);
$sheet->setCellValue('M' . $row, $value[12]);
$sheet->setCellValue('N' . $row, $value[13]);
$nextKey = isset($data_array[$index + 1]) ? $data_array[$index + 1][2] : null;
if ($row >= $startRow && (($previousKey != $nextKey) || ($nextKey == null))) {
$cellToMergeJ = 'J' . $startRow . ':J' . $row;
$cellToMergeK = 'K' . $startRow . ':K' . $row;
$cellToMergeL = 'L' . $startRow . ':L' . $row;
$sheet->mergeCells($cellToMergeJ);
$sheet->mergeCells($cellToMergeK);
$sheet->mergeCells($cellToMergeL);
$sheet->cells('J' . $startRow . ':J' . $row, function ($cellsJ) {$cellsJ->setValignment('center');});
$sheet->cells('K' . $startRow . ':K' . $row, function ($cellsK) {$cellsK->setValignment('center');});
$sheet->cells('L' . $startRow . ':L' . $row, function ($cellsL) {$cellsL->setValignment('center');});
$startRow = -1;
}
$row++;
}
});
})->download('xlsx');
}
Подробнее здесь: https://stackoverflow.com/questions/651 ... nd-php-7-4
Laravel-Excel 3.1 с Laravel Framework 6.2 и PHP 7.4 ⇐ Php
Кемеровские программисты php общаются здесь
-
Anonymous
1739770198
Anonymous
У меня есть проблемы с Laravel-Excel 3.1 после того, как я обновил версию Laravel и PHP-версию, я получил некоторое требование от Laravel для обновления Laravel-Excel. После этого у меня возникла проблема с Excel-Export, не поддерживаю новую версию (3.1), прежде чем я использую 2.1. Кто -нибудь может помочь обновить мой код в настоящее время выше? пожалуйста! И спасибо, ребята! < /p>
private function export_customer_invoice_report($customer_invs)
{
$data_array = array([
'Issue Date',
'Purchase Order Invoice',
'Bag ID',
'SKU',
'Color-Size',
'QTY',
'Sale Price',
'Additional Discount',
'Actual Sale Price',
'Delivery Fee',
'Customer Balance',
'Pre-Paid Amount',
'Supplier Actual Price',
'Remark']);
foreach ($customer_invs as $key => $value) {
$product_variants = Helper::get_pro_option_id($value->order_item_id);
$doubleSpace = strip_tags($product_variants);
$singleSpace_product_variants = str_replace("\n ", "", $doubleSpace);
$issue_date = Helper::dateTimeDisplay($value->created_at);
$additional_dis = $value->additional_discount_percent ? $value->additional_discount_percent : 0;
$sale_price_after_disc = ($value->unit_price * $value->count_item) - ((($value->unit_price * $value->count_item) * $value->discount_percent) / 100);
$total_sale_price_discount_addit = ($sale_price_after_disc * $value->additional_discount_percent) / 100;
$actual_sale_price = $sale_price_after_disc - $total_sale_price_discount_addit;
// check if supplier actual price is zero, take from supplier price instead
$supplier_actual_price = $value->supplier_order_actual_price > 0
? $value->supplier_order_actual_price
: $value->supplier_price;
$data_list = array(
$issue_date,
$value->invoice_id,
$value->bag_id,
OrderItem::getProductSKU($value->order_item_id),
$singleSpace_product_variants,
$value->count_item,
'$' . number_format($sale_price_after_disc, 2),
'%' . $additional_dis,
'$' . number_format($actual_sale_price, 2),
'$' . number_format($value->delivery_price, 2),
'$' . number_format($value->customer_balance, 2),
'$' . number_format($value->prepaid_amount, 2),
'¥' . number_format($supplier_actual_price, 2),
$value->note,
);
array_push($data_array, $data_list);
}
Excel::create('customer_invoice_report', function ($excel) use ($data_array) {
// Set the title
$excel->setTitle('no title');
$excel->setCreator('no no creator')->setCompany('no company');
$excel->setDescription('report file');
$excel->sheet('sheet1', function ($sheet) use ($data_array) {
$sheet->cells('A1:M1', function ($cells) {
$cells->setBackground('#e7e7e7');
$cells->setFontWeight('bold');
});
$row = 1;
$startRow = -1;
$previousKey = '';
foreach ($data_array as $index => $value) {
if ($startRow == -1) {
$startRow = $row;
$previousKey = $value[2];
}
$sheet->setCellValue('A' . $row, $value[0]);
$sheet->setCellValue('B' . $row, $value[1]);
$sheet->setCellValue('C' . $row, $value[2]);
$sheet->setCellValue('D' . $row, $value[3]);
$sheet->setCellValue('E' . $row, $value[4]);
$sheet->setCellValue('F' . $row, $value[5]);
$sheet->setCellValue('G' . $row, $value[6]);
$sheet->setCellValue('H' . $row, $value[7]);
$sheet->setCellValue('I' . $row, $value[8]);
$sheet->setCellValue('J' . $row, $value[9]);
$sheet->setCellValue('K' . $row, $value[10]);
$sheet->setCellValue('L' . $row, $value[11]);
$sheet->setCellValue('M' . $row, $value[12]);
$sheet->setCellValue('N' . $row, $value[13]);
$nextKey = isset($data_array[$index + 1]) ? $data_array[$index + 1][2] : null;
if ($row >= $startRow && (($previousKey != $nextKey) || ($nextKey == null))) {
$cellToMergeJ = 'J' . $startRow . ':J' . $row;
$cellToMergeK = 'K' . $startRow . ':K' . $row;
$cellToMergeL = 'L' . $startRow . ':L' . $row;
$sheet->mergeCells($cellToMergeJ);
$sheet->mergeCells($cellToMergeK);
$sheet->mergeCells($cellToMergeL);
$sheet->cells('J' . $startRow . ':J' . $row, function ($cellsJ) {$cellsJ->setValignment('center');});
$sheet->cells('K' . $startRow . ':K' . $row, function ($cellsK) {$cellsK->setValignment('center');});
$sheet->cells('L' . $startRow . ':L' . $row, function ($cellsL) {$cellsL->setValignment('center');});
$startRow = -1;
}
$row++;
}
});
})->download('xlsx');
}
Подробнее здесь: [url]https://stackoverflow.com/questions/65146854/laravel-excel-3-1-with-laravel-framework-6-2-and-php-7-4[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия