내 데이터베이스에서 데이터를로드하고,이 사이트에서 발견하는 방법을 통해 Excel 파일에 수출하고 있습니다 : 그것은 작동 http://www.appservnetwork.com/modules.php?name=News&file=article&sid=8형식 PHP
하지만 내가하고 싶은 지금 내보내기 전에 텍스트의 서식을 지정합니다. 글꼴 및 텍스트 크기를 변경합니다. 아무도이 작업을 수행하는 방법에 대한 아이디어가 있습니까?
내 데이터베이스에서 데이터를로드하고,이 사이트에서 발견하는 방법을 통해 Excel 파일에 수출하고 있습니다 : 그것은 작동 http://www.appservnetwork.com/modules.php?name=News&file=article&sid=8형식 PHP
하지만 내가하고 싶은 지금 내보내기 전에 텍스트의 서식을 지정합니다. 글꼴 및 텍스트 크기를 변경합니다. 아무도이 작업을 수행하는 방법에 대한 아이디어가 있습니까?
PEAR :: Package :: Spreadsheet_Excel_Writer
클래스를 사용하여 PHP 5의 Excel 스프레드 시트를 작성했습니다. 이 패키지로 많은 것을 할 수 있습니다.
솔루션을 배포하려는 속도에 따라 하나의 방법은 HTML 표 태그를 사용하여 스타일 표식을 사용하여 모든 데이터를 표에 저장 한 다음 PHP 헤더의 옵션을 사용하여 브라우저가 저장하도록 강제하는 것입니다 .xls 파일입니다. 개념의 증거를 들어
, 메모장에이 코드를 복사 .XLS로 저장 한 다음 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>
아니고 가장 우아한 해결책을하지만, 절대적으로 필요에 맞게됩니다.
TinyButStrong 템플릿 시스템 (www.tinybutstrong.com)에는 엑셀 템플릿에 쓸 수있는 선택적 플러그인이 있습니다.
저는 이것을 많이 사용했습니다. 특히 깃발에 따라 HTML 또는 Excel로 페이지를 작성할 수 있으므로 매우 편리합니다. 일반적으로 보고서에는 '페이지에 표시'및 '쓰기 기능'옵션이 있습니다.
나는 몇 시간에 php_writeexcel을 사용했으며 많이 좋아했습니다! :)
<?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;
?>
오래된 게시물이지만 유용합니다. 고마워요! – Lucas
간단하고 우아한 솔루션. –