удалить дублирующее значение, но оставить остальные значения строк PHPEXCEL MYSQL

Здравствуйте, я знаю, что делаю ссылку на другой вопрос (удалить дублирующее значение, но сохранить остальные значения строки)
но мое немного отличается, потому что я пытаюсь применить его с помощью библиотеки Excelphp.

Моя проблема такая же, как и вопрос, который я упоминал ранее, но я не знаю, как получить его, используя php, excelphp и Myslq.

Я пытаюсь отобразить файл .xls, как это изображение http://i.stack.imgur.com/tQDrY.jpg

вот код, который у меня есть сейчас, он работает нормально, потому что показывает результаты, но я хочу удалить дублирующее значение в некоторых столбцах и сохранить остальные значения.

это показывает результат, как это изображение http://i.stack.imgur.com/wrbqw.jpg
excel.php

     <?php
$conexion = new mysqli('localhost','root','','sistema_auxiliarbodegacocina',3306);
if (mysqli_connect_errno()) {
printf("La conexión con el servidor de base de datos falló: %s\n", mysqli_connect_error());
exit();
}

//$idCuest = $_GET['idCuest'];
//$d3 = $_GET['d3'];
$date1 = $_GET['date1'];
$date2 = $_GET['date2'];
$consulta = " SELECT
ordenes.id as idorden,
ordenes.fecha_apertura,
hensp_menu.id as idmenu,
hensp_menu.nombre_menu,
hensp_porciones.nombre_porcion,
hensp_ingredientes.nombre_ingrediente,
hensp_ingredientes.codigo_unico,
hensp_porciones.unico_porcion,
porcion_ingredientes_seleccionados.cantidad_ingrediente,
porcion_ingredientes_seleccionados.cantidad_orden,
porcion_ingredientes_seleccionados.cantidad_ingrediente * porcion_ingredientes_seleccionados.cantidad_orden as total,
porcion_ingredientes_seleccionados.unidad_medida_ingrediente
FROM porcion_ingredientes_seleccionadosINNER JOIN ordenes on ordenes.id = porcion_ingredientes_seleccionados.idorden

INNER JOIN hensp_menu  on hensp_menu.id = porcion_ingredientes_seleccionados.idmenu

Inner join hensp_porciones on hensp_porciones.id = porcion_ingredientes_seleccionados.idporcion

Inner join hensp_ingredientes on hensp_ingredientes.id = porcion_ingredientes_seleccionados.idingredientesWHERE estado= '0'  and fecha_entrega >= '".$date1."' and fecha_entrega <= '".$date2."'

order by  ordenes.id ";
$resultado = $conexion->query($consulta);
if($resultado->num_rows > 0 ){

date_default_timezone_set('America/El_Salvador');

if (PHP_SAPI == 'cli')
die('Este archivo solo se puede ver desde un navegador web');

/** Se agrega la libreria PHPExcel */
require_once 'lib/PHPExcel/PHPExcel.php';

// Se crea el objeto PHPExcel
$objPHPExcel = new PHPExcel();

// Se asignan las propiedades del libro
$objPHPExcel->getProperties()->setCreator("Ing. Dennis Fuentes") //Autor
->setTitle("Registro del Sistema Auxiliar ".$date1."'-'".$date2."'")
->setCategory("Reporte excel");

$tituloReporte = "Registro de Órdenes Fecha ".$date1."  -  ".$date2."";
$titulosColumnas = array('Fecha', '#orden', 'nombre_menu','CODIGO','nombre porcion', 'CODIGO','nombre_ingrediente', '#numero de porciones','cantidad por porcion', 'total orden', 'unidad de medida');

$objPHPExcel->setActiveSheetIndex(0)
->mergeCells('A1:G1');

// Se agregan los titulos del reporte
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1',$tituloReporte)
->setCellValue('A3',  $titulosColumnas[0])
->setCellValue('B3',  $titulosColumnas[1])
->setCellValue('C3',  $titulosColumnas[2])
->setCellValue('D3',  $titulosColumnas[3])
->setCellValue('E3',  $titulosColumnas[4])
->setCellValue('F3',  $titulosColumnas[5])
->setCellValue('G3',  $titulosColumnas[6])
->setCellValue('H3',  $titulosColumnas[7])
->setCellValue('I3',  $titulosColumnas[8])
->setCellValue('J3',  $titulosColumnas[9])
->setCellValue('K3',  $titulosColumnas[10]);//Se agregan los datos de los alumnos
$i = 4;
$last_course = null;
while ($fila = $resultado->fetch_array()) {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A'.$i,  $fila['fecha_apertura'])
->setCellValue('B'.$i,  $fila['idorden'])
->setCellValue('C'.$i,  $fila['nombre_menu'])
->setCellValue('D'.$i,  utf8_encode($fila['unico_porcion']))
->setCellValue('E'.$i,  utf8_encode($fila['nombre_porcion']))
->setCellValue('F'.$i, utf8_encode($fila['codigo_unico']))
->setCellValue('G'.$i, utf8_encode($fila['nombre_ingrediente']))
->setCellValue('H'.$i, utf8_encode($fila['cantidad_orden']))
->setCellValue('I'.$i, utf8_encode($fila['cantidad_ingrediente']))
->setCellValue('J'.$i, utf8_encode($fila['total']))
->setCellValue('K'.$i, utf8_encode($fila['unidad_medida_ingrediente']));
$i++;
}

$estiloTituloReporte = array(
'font' => array(
'name'      => 'Verdana',
'bold'      => true,
'italic'    => false,
'strike'    => false,
'size' =>16,
'color'     => array(
'rgb' => 'FFFFFF'
)
),
'fill' => array(
'type'  => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'd1d1dc ')
),
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM
)
),
'alignment' =>  array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical'   => PHPExcel_Style_Alignment::VERTICAL_CENTER,
'rotation'   => 0,
'wrap'          => TRUE
)
);

$estiloTituloColumnas = array(
'font' => array(
'name'      => 'Arial',
'bold'      => true,
'color'     => array(
'rgb' => 'FFFFFF'
)
),
'fill'  => array(
'type'      => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR,
'rotation'   => 90,
'startcolor' => array(
'rgb' => 'c47cf2'
),
'endcolor'   => array(
'argb' => 'FF431a5d'
)
),
'borders' => array(
'top'     => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM ,
'color' => array(
'rgb' => '143860'
)
),
'bottom'     => array(
'style' => PHPExcel_Style_Border::BORDER_MEDIUM ,
'color' => array(
'rgb' => '143860'
)
)
),
'alignment' =>  array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical'   => PHPExcel_Style_Alignment::VERTICAL_CENTER,
'wrap'          => TRUE
));

$estiloInformacion = new PHPExcel_Style();
$estiloInformacion->applyFromArray(
array(
'font' => array(
'name'      => 'Arial',
'color'     => array(
'rgb' => '000000'
)
),

'borders' => array(
'left'     => array(
'style' => PHPExcel_Style_Border::BORDER_THIN ,
'color' => array(
'rgb' => '3a2a47'
)
)
)
));

$objPHPExcel->getActiveSheet()->getStyle('A1:K1')->applyFromArray($estiloTituloReporte);
$objPHPExcel->getActiveSheet()->getStyle('A3:K3')->applyFromArray($estiloTituloColumnas);
$objPHPExcel->getActiveSheet()->setSharedStyle($estiloInformacion, "A4:K".($i-1));

for($i = 'A'; $i <= 'K'; $i++){
$objPHPExcel->setActiveSheetIndex(0)
->getColumnDimension($i)->setWidth(25);
}// Se asigna el nombre a la hoja
$objPHPExcel->getActiveSheet()->setTitle('Listado de Órdenes ');

// Se activa la hoja para que sea la que se muestre cuando el archivo se abre
$objPHPExcel->setActiveSheetIndex(0);
// Inmovilizar paneles
//$objPHPExcel->getActiveSheet(0)->freezePane('A4');
$objPHPExcel->getActiveSheet(0)->freezePaneByColumnAndRow(0,4);// Se manda el archivo al navegador web, con el nombre que se indica (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="Listado General de Ordenes '.$date1.' - '.$date2.'.xlsx"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
exit;

}
else{
print_r('No hay resultados para mostrar');
}
?>

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector