Last active
November 21, 2020 19:25
-
-
Save kiichi/aeb3964b68d40f75246869c0c456c936 to your computer and use it in GitHub Desktop.
Generate Excel using HTML format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function downloadExcel($table_html, $style_html){ | |
$file="gmdi.xls"; | |
header("Content-type: application/vnd.ms-excel"); | |
header("Content-Disposition: attachment; filename=$file"); | |
$excel = '<html xmlns:x="urn:schemas-microsoft-com:office:excel"> | |
<head> | |
<!--[if gte mso 9]> | |
<xml> | |
<x:ExcelWorkbook> | |
<x:ExcelWorksheets> | |
<x:ExcelWorksheet> | |
<x:Name>Sheet 1</x:Name> | |
<x:WorksheetOptions> | |
<x:Print> | |
<x:ValidPrinterInfo/> | |
</x:Print> | |
</x:WorksheetOptions> | |
</x:ExcelWorksheet> | |
</x:ExcelWorksheets> | |
</x:ExcelWorkbook> | |
</xml> | |
<![endif]--> | |
'.$style_html.' | |
</head> | |
<body> | |
'.$table_html.' | |
</body> | |
</html>'; | |
echo $excel; | |
exit(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html xmlns:x="urn:schemas-microsoft-com:office:excel"> | |
<head> | |
<!--[if gte mso 9]> | |
<xml> | |
<x:ExcelWorkbook> | |
<x:ExcelWorksheets> | |
<x:ExcelWorksheet> | |
<x:Name>Sheet 1</x:Name> | |
<x:WorksheetOptions> | |
<x:Print> | |
<x:ValidPrinterInfo/> | |
</x:Print> | |
</x:WorksheetOptions> | |
</x:ExcelWorksheet> | |
</x:ExcelWorksheets> | |
</x:ExcelWorkbook> | |
</xml> | |
<![endif]--> | |
<style> | |
* { } | |
</style> | |
</head> | |
<body> | |
<table><tr><td>hello</td></tr></table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment