Answer the question
In order to leave comments, you need to log in
How to export html table to excel?
$file="demo.xls";
$test="<table ><tr><td>Cell 1</td><td>Cell 2</td></tr></table>";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $test;
Answer the question
In order to leave comments, you need to log in
If we are talking about Bitrix24, then for a start it would not be bad not to display the contents of the buffer before calling your code.
This can be done with code:
global $APPLICATION;
$APPLICATION->RestartBuffer();
\CMain::FinalActions();
global $APPLICATION;
$APPLICATION->RestartBuffer();
$file="demo.xls";
$test="<table ><tr><td>Cell 1</td><td>Cell 2</td></tr></table>";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $test;
\CMain::FinalActions();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question