I am working on the reporting part of my project, the project contain hundreds of dynamic generated reports and each report contain images and formatted followed by Table. And all these reports need to be downloadable in doc/docx (Ms Word), xls /xlsx(MS Excel) and PDF
For this I want to Convert the Generated HTML report to the corresponding file for this I am using following code
function export_attendance_view_doc($htmlcontent){
header("Content-Type: application/vnd.msword");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=attendance_report.doc");
echo $htmlcontent;
}
function export_attendance_view_xls($htmlcontent){
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=attendance_report.xls");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=attendance_report.doc");
echo $htmlcontent;
}
Using the above code I am getting the doc and xls file but the issue is that the image is not rendering in the file if the script is run in live server working fine in localhost if I am using full url in <img src
not displaying image in local if using relative path. Same in the case of Excel file.