una tabla formato exportar ejemplos div desde descargar datos dar con celdas bootstrap php export-to-excel

tabla - Formatee el texto en un archivo de Excel mediante PHP



header excel php (6)

Estoy cargando datos de mi base de datos y exportándolos a un archivo de Excel a través de un método que encontré en este sitio: http://www.appservnetwork.com/modules.php?name=News&file=article&sid=8

Funciona, pero lo que quiero hacer ahora es formatear el texto antes de exportarlo: cambie la fuente y el tamaño del texto. ¿Alguien tiene alguna idea sobre cómo hacer esto?


Dependiendo de la velocidad con la que desee implementar su solución, un método es simplemente usar la etiqueta de tabla HTML, almacenar todos sus datos en tablas usando el marcado de estilo, y luego usar la opción del encabezado PHP para forzar que el navegador guarde como una. archivo xls.

Como prueba de concepto, copie este código en el bloc de notas, guárdelo como .xls y luego ábralo con Excel:

<table> <tr><th>Column 1</th><th>Column 2</th></tr> <tr><td style="font-size:200%">Answer 1</td><td style="color:#f00">Answer 2</td></tr> <tr><td colspan="2" style="font-weight:bold">Answer 3 with 2 columns</td></tr> </table>

No es la solución más elegante, pero satisfará absolutamente sus necesidades.


El sistema de plantillas TinyButStrong (www.tinybutstrong.com) tiene un complemento opcional que le permite escribir en plantillas Excel.

Lo he usado mucho. Es particularmente bueno en que puede configurar la página para que escriba en HTML o Excel dependiendo de un indicador, por lo que mis informes ofrecen opciones de ''mostrar en la página'' y ''escribir en Excel''.


PHPExcel le brinda las facilidades para hacer esto y más.




<?php include ''../include/config.php''; $sql = "SELECT SQL_CALC_FOUND_ROWS ".DB_TBL_TUTORS_RECAPS.".id, ".DB_TBL_TUTORS_RECAPS.".date_of_tutoring_session, ".DB_TBL_TUTORS_RECAPS.".created, ".DB_TBL_TUTORS_RECAPS.".hours_tutored, ".DB_TBL_TUTORS_RECAPS.".billable_travel, ".DB_TBL_TUTORS_RECAPS.".billable_additional, ".DB_TBL_TUTORS_RECAPS.".type_of_tutoring, ".DB_TBL_TUTORS_RECAPS.".additional_comments, ".DB_TBL_TUTORS_RECAPS.".total_billable, ".DB_TBL_TUTORS_RECAPS.".materials_covered_during_session, ".DB_TBL_TUTORS_RECAPS.".next_scheduled_session_location, ".DB_TBL_TUTORS_RECAPS.".rate, ".DB_TBL_TUTORS_RECAPS.".tutor_pay_rate, ".DB_TBL_APPLICANTS.".first_name as tutor_first_name, ".DB_TBL_APPLICANTS.".last_name as tutor_last_name, ".DB_TBL_PIPELINE.".tutor_match_notes, ".DB_TBL_PIPELINE.".date_of_submission, ".DB_TBL_PIPELINE.".tutor_name, ".DB_TBL_PIPELINE.".tutor_id, ".DB_TBL_CLIENTS.".id as client_id, ".DB_TBL_CLIENTS.".first_name, ".DB_TBL_CLIENTS.".last_name, ".DB_TBL_CLIENTS.".location_name, ".DB_TBL_CLIENTS.".last_name, ".DB_TBL_CHILDREN.".id as child_id, ".DB_TBL_CHILDREN.".last_name as last, ".DB_TBL_CHILDREN.".first_name as first FROM ".DB_TBL_TUTORS_RECAPS." LEFT JOIN ".DB_TBL_PIPELINE." ON ".DB_TBL_PIPELINE.".id= ".DB_TBL_TUTORS_RECAPS.".pipeline_id LEFT JOIN ".DB_TBL_CHILDREN." ON ".DB_TBL_CHILDREN.".id= ".DB_TBL_TUTORS_RECAPS.".child_id LEFT JOIN ".DB_TBL_CLIENTS." ON ".DB_TBL_CLIENTS.".id= ".DB_TBL_TUTORS_RECAPS.".client_id LEFT JOIN ".DB_TBL_TUTORS." ON ".DB_TBL_TUTORS_RECAPS.".tutor_id= ".DB_TBL_TUTORS.".id LEFT JOIN ".DB_TBL_APPLICANTS." ON ".DB_TBL_APPLICANTS.".id= ".DB_TBL_TUTORS.".applicant_id WHERE " . DB_TBL_CLIENTS . ".status = ''Existing'' AND " . DB_TBL_APPLICANTS . ".status = ''Existing'' AND " . DB_TBL_PIPELINE . ".status = ''Existing'' AND " . DB_TBL_TUTORS_RECAPS . ".is_deleted = ''0'' GROUP BY " . DB_TBL_TUTORS_RECAPS . ".id ORDER BY " . DB_TBL_TUTORS_RECAPS . ".created DESC "; $totallogs = $db->query($sql); $filename = "Tutoring_Log.xls"; $contents = "Recap# /t Tutor Name /t Client Name /t Child Name /t Type of tutoring /t Date of Tutoring session /t Hours tutored /t Billable Travel /t Billable Additional /t Total Billable /t Client Rate /t Tutor Pay Rate /t /n"; $contents .= " /n"; while($tutorRecords = $db->fetchNextObject($totallogs)){ $contents .= "".$tutorRecords->id." /t ".$tutorRecords->tutor_first_name.'' ''.$tutorRecords->tutor_last_name." /t ".$tutorRecords->first_name.'' ''.$tutorRecords->last_name." /t ".$tutorRecords->first.'' ''.$tutorRecords->last." /t ".$globalsConstant[''type_of_tutoring''][$tutorRecords->type_of_tutoring]." /t ".date(MDY,$tutorRecords->date_of_tutoring_session)." /t ".str_replace(''.'','':'',$tutorRecords->hours_tutored)." /t ".str_replace(''.'','':'',$tutorRecords->billable_travel)." /t ".str_replace(''.'','':'',$tutorRecords->billable_additional)." /t ".str_replace(''.'','':'',$tutorRecords->total_billable)." /t ".CURRENCY.$tutorRecords->rate." /t ".CURRENCY.$tutorRecords->tutor_pay_rate." /t /n"; } header(''Content-type: application/ms-excel''); header(''Content-Disposition: attachment; filename=''.$filename); echo $contents; ?>