如何使用PHP导出数据和base64图像来优化?

我试图出口以下擅长,但图像不通过。

例:

$today = date("d/m/y : H:i:s", time()); header ("Content-Type: application/x-msexcel"); header ("Content-Disposition: attachment; filename=\"export.xls\"" ); echo ' <table> <tr> <th nowrap="nowrap">Client ID</th> <th nowrap="nowrap">Client Name</th> <th nowrap="nowrap">No. of Staff</th> <th nowrap="nowrap">No. of Events</th> <th nowrap="nowrap">Fail all\'s</th> <th nowrap="nowrap">Fail Section</th> <th nowrap="nowrap">Fail all %</th> </tr> <tr> <td nowrap="nowrap">8</td> <td nowrap="nowrap">SEAI</td> <td nowrap="nowrap"><div> 17 </div></td> <td nowrap="nowrap"><div> 354 </div></td> <td nowrap="nowrap"><div> 7 </div></td> <td nowrap="nowrap"><div> 0 </div></td> <td nowrap="nowrap"><div> 1.98% </div></td> </tr> </table> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA24AAAEsCAYAAAC7XuApAAAWw0lEQVR4nO3dT2scd57HcV/yiHKf257mT47zDPoQMAOzLJNkyBwNjcH4kmXsTMbgPmgV55SsmxmoYE1AMPgQDTQdCAi0B8HQGpCRs7HJzsB3D6Y61a1qqaXq+qm6fq8XvCFWWq1SLs6Hqq669fbgwVu/+OCzT3723qevf/fHr84efP71650vv4n/kiRJkiQlbefLb+LB51+//t0fvzr76W8+ff3O+589fHvw4K1b77z/5Pf/8Z9ffv/dqx8CAACAbnj5/Q/x64+K79/54MlHt37+3pNX//v6/276mAAAAFjy3asf4mfvffr61oeffPXypg8GAACAer/9+C8vb/3hi4N/3fSBAAAAUO/B5wf/vPX4T5ObPg4AAABWePynSRhuAAAAHWa4AQAAdJzhBgAA0HGGGwAAQMcZbgAAAB1nuAEAAHSc4QYAANBxhhtATz0Z78VPfvmrcz0Z7135vf568E385Je/ir8efNPCkV5deTzVVh3b8mtX/f5171l2/Pd/XPnYqsfTtf9+AGwfww2gp8rhVh0d5ddSDohNj5a7D3fP/V7Hf/9H/OSXv4q7D3fPvX7V11cd51V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oi7t+/H/fv3z/3moODg/nXS9XXF0Vx4WvL15X/vvoe5euPjo7m/1x93e7u7rn3q6o7jrqvvXjxInZ3d+fvd3R0NH/NukPRcAMAADauHG7LLQ+3o6Ojc0NrebhF/Dj6ytGzrO61y8ezPP6WB1n1+5Zfv6zuOJZ/l93d3Tg6Opr/t3jx4sV8IJbHcHR0tPJnVBluAADAxq17xu3g4GDhTNjya5a/fnBwMD+TVVX32vKfq2fzSnWjaXnwlSOr7ufVHcfy18rfrToCq68x3AAAgBu17nCrnqWqnpkqX7P8vRedcat77fLliqV1httFX7/qGTfDDQAA6JyrfMat+lmyy864RcTC59Gqn3Fb9XPK965eTlk3msrPpx0cHCx8Dm3VsKw7jos+41Z+z7WH28MvDv651qsBAABaUjf2eOP3n3/9z1sffvLVy5s+EAAAIE+r7vzIj3778V9e3vr5e09evfz+h5s+FgAAAJZ89+qH+Pl7T17deuf9J7//94++fPXdK+MNAACgK15+/0P8+qPi+3c+ePLRrbcHD976xQefffLT33z6+v2Hey8//uLgX3/477+FJEmSJCl9H39x8K/3H+69/OlvPn39iw8+e/D24MFb/w8FVkJZAxfZ3wAAAABJRU5ErkJggg==" /> '; 

我已经尝试了以下成功:

 echo file_get_contents(base64_decode($img)); 

有和没有标签,有和没有file_get_contents和base64_decode。

我觉得应该是可能的,但我错过了什么:(有没有人有任何想法?

谢谢!!!

从我看到的,你正在试图创build一个Excel文件(XLS)保持头。

标题是不够的!

你需要一套库。 我会build议你使用PHPExcel你可以轻松地添加图像到它。 保持这个库方便! 它可以做更多的东西。

一旦你安装了它,你可以参考这个答案更多的一步一步的指示。

尝试使用PHPExcel的完整解决scheme,我也推荐这个工作。

http://phpexcel.codeplex.com/discussions/271473