Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将带有文本和图像的HTML表格导出到excel_Javascript_Php_Jquery_Html_Export To Excel - Fatal编程技术网

Javascript 将带有文本和图像的HTML表格导出到excel

Javascript 将带有文本和图像的HTML表格导出到excel,javascript,php,jquery,html,export-to-excel,Javascript,Php,Jquery,Html,Export To Excel,其他几个帖子也问过这个问题,但没有提供解决方案。 我想从带有照片和文本的HTML表格中获取Excel输出。我找到了以下两个Excel输出插件(我认为是最完整的插件): 及 国家 人口 日期 %通用电气 照片 中国 1,363,480,000 2014年3月24日 19.1 印度 1,241,900,000 2014年3月24日 17.4 美国 317,746,000 2014年3月24日 4.44 印度尼西亚 249,866,000 2013年7月1日 3.49 巴西 201,032,71

其他几个帖子也问过这个问题,但没有提供解决方案。 我想从带有照片和文本的HTML表格中获取Excel输出。我找到了以下两个Excel输出插件(我认为是最完整的插件):


国家
人口
日期
%通用电气
照片
中国
1,363,480,000
2014年3月24日
19.1
印度
1,241,900,000
2014年3月24日
17.4
美国
317,746,000
2014年3月24日
4.44
印度尼西亚
249,866,000
2013年7月1日
3.49
巴西
201,032,714
2013年7月1日
2.81

出口为

<a href="#" onClick="$('#customers').tableExport({type:'excel',escape:'false'});">export</a>

我还包括了一个包含图像的专栏,如所示

如果我将此表导出到Excel,则不会显示图像。那么我怎样才能将这些图像和数据一起导出呢。应该使用哪种输出


如果在Excel输出中不可能,输出应该使用什么格式?

如果您不需要原始的Excel文件,而是一个显示Excel表中的列的文件(并且可以在Excel或LeBealOffice Calc或许多其他程序中编辑),您应该考虑使用.< /P> 它易于创建和编辑,不需要使用任何插件或库

可能输出 转换为Excel 但如果你真的想要Excel文件, 我会是你的朋友。它使用CSV文件创建完全可操作的Excel文件

include 'PHPExcel/IOFactory.php';

$objReader = PHPExcel_IOFactory::createReader('CSV');

// If the files uses a delimiter other than a comma (e.g. a tab), then tell the reader
$objReader->setDelimiter("\t");
// If the files uses an encoding other than UTF-8 or ASCII, then tell the reader
$objReader->setInputEncoding('UTF-16LE');

$objPHPExcel = $objReader->load('MyCSVFile.csv');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('MyExcelFile.xls');
示例代码段来自:

图像插入 PHP Excel提供了包含图像的功能:

$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('PHPExcel logo');
$objDrawing->setDescription('PHPExcel logo');
$objDrawing->setPath('./images/phpexcel_logo.gif');       // filesystem reference for the image file
$objDrawing->setHeight(36);            
$objDrawing->setCoordinates('D24');    
$objDrawing->setOffsetX(10);                
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());

来自的代码段。

如何将其导出到Excel?不要告诉我你只是将这个HTML标记保存到一个扩展名为.xls的文件中?@MarkBaker第一个插件
http://ngiriraj.com/pages/htmltable_export/demo.php
我已将其用于输出。请看演示:@MarkBaker我可以用phpexcel来做这件事吗?是的,你可以,尽管你会在服务器端而不是客户端运行它
include 'PHPExcel/IOFactory.php';

$objReader = PHPExcel_IOFactory::createReader('CSV');

// If the files uses a delimiter other than a comma (e.g. a tab), then tell the reader
$objReader->setDelimiter("\t");
// If the files uses an encoding other than UTF-8 or ASCII, then tell the reader
$objReader->setInputEncoding('UTF-16LE');

$objPHPExcel = $objReader->load('MyCSVFile.csv');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('MyExcelFile.xls');
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('PHPExcel logo');
$objDrawing->setDescription('PHPExcel logo');
$objDrawing->setPath('./images/phpexcel_logo.gif');       // filesystem reference for the image file
$objDrawing->setHeight(36);            
$objDrawing->setCoordinates('D24');    
$objDrawing->setOffsetX(10);                
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());