PHPExcel establece mismas propiedades, etc contenido en varias hojas a la vez
Pregunta
¿Hay alguna forma de establecer las mismas propiedades (colores, altura de fila, alineaciones) y el contenido (nombres se oye) para todas las hojas a la vez con PHPExcel? ¿Cómo?
Gracias.
Solución
Si va a crear todas esas hojas de sí mismo. Establecer las propiedades de la primera hoja que se crea, a continuación, el clon esa hoja y adjuntar el nuevo clon de volver al mismo libro. Esto debería copiar todos los datos de las celdas existentes y la información de estilo de la hoja de cálculo original.
// Create a new PHPExcel object with a single sheet
$objPHPExcel = new PHPExcel();
// Set any styles here against the currently active sheet in $objPHPExcel
// Get the current sheet with all its newly-set style properties
$objWorkSheetBase = $objPHPExcel->getSheet();
// Create a clone of the current sheet, with all its style properties
$objWorkSheet1 = clone $objWorkSheetBase;
// Set the newly-cloned sheet title
$objWorkSheet1->setTitle('Cloned Sheet');
// Attach the newly-cloned sheet to the $objPHPExcel workbook
$objPHPExcel->addSheet($objWorkSheet1);
Es útil señalar que se puede definir estilos de una célula, incluso antes de escribir los datos a esa celda
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow