如何将HTML报表轻松转换成XLS报表?
- 内容介绍
- 文章标签
- 相关推荐
本文共计821个文字,预计阅读时间需要4分钟。
使用PHPExcel将table报表转换成Excel格式(依赖我的php-library库)* 使用PHP读取数据库并生成xls报表过于繁琐(尤其是含有联表查询、单元格合并等)* 相对于再做一个跟web页面展示一致的一致复杂
用phpexcel将table 报表转换成excel形式(依赖我的php-library库)
*
* 用PHP读取数据库并生成xls报表太复麻烦了(尤其是含有联表查询、单元格合并)
* 相当于再做一个跟web页面显示一致同样复杂的统计,于是诞生了本页面,
* 本页面的核心思想是,先用html表格将数据渲染成报表,在点击导出时直接
* 用js将表格的头部、表格体的所有单元格数据(包括其colspan、rowspan属性)异步POST传递给本页面
* 保存数据后,再跳转至本页面
* -- Javascript code like this:
* function export_func(){ //点击导出按钮的事件处理函数(处理的表格ID:data-table)
* var col_set= new Array();
* var data_set= new Array();
* $("#data-table thead tr").each(function(){
* var col_row = new Array();
* $("th", this).each(function(){
* col_row.push([$(this).html(), $(this).attr('colspan'), $(this).attr('rowspan')]);
* })
* col_set.push(col_row);
* });
* $("#data-table tbody tr").each(function(){
* var data_row = new Array();
* $("td",this).each(function(){
* data_row.push([$(this).html(), $(this).attr('colspan'), $(this).attr('rowspan')]);
* });
* data_set.push(data_row);
* });
* $.post("form-convert-xls.php",{col:$.toJSON(col_set),data:$.toJSON(data_set)},function(data){
* if(data=='ok'){
* window.location="form-convert-xls.php";
* }
* })
* }
* -- Html code like this:
*
*
*
*
列标题 *
列标题 *
列标题 *
*
*
本文共计821个文字,预计阅读时间需要4分钟。
使用PHPExcel将table报表转换成Excel格式(依赖我的php-library库)* 使用PHP读取数据库并生成xls报表过于繁琐(尤其是含有联表查询、单元格合并等)* 相对于再做一个跟web页面展示一致的一致复杂
用phpexcel将table 报表转换成excel形式(依赖我的php-library库)
*
* 用PHP读取数据库并生成xls报表太复麻烦了(尤其是含有联表查询、单元格合并)
* 相当于再做一个跟web页面显示一致同样复杂的统计,于是诞生了本页面,
* 本页面的核心思想是,先用html表格将数据渲染成报表,在点击导出时直接
* 用js将表格的头部、表格体的所有单元格数据(包括其colspan、rowspan属性)异步POST传递给本页面
* 保存数据后,再跳转至本页面
* -- Javascript code like this:
* function export_func(){ //点击导出按钮的事件处理函数(处理的表格ID:data-table)
* var col_set= new Array();
* var data_set= new Array();
* $("#data-table thead tr").each(function(){
* var col_row = new Array();
* $("th", this).each(function(){
* col_row.push([$(this).html(), $(this).attr('colspan'), $(this).attr('rowspan')]);
* })
* col_set.push(col_row);
* });
* $("#data-table tbody tr").each(function(){
* var data_row = new Array();
* $("td",this).each(function(){
* data_row.push([$(this).html(), $(this).attr('colspan'), $(this).attr('rowspan')]);
* });
* data_set.push(data_row);
* });
* $.post("form-convert-xls.php",{col:$.toJSON(col_set),data:$.toJSON(data_set)},function(data){
* if(data=='ok'){
* window.location="form-convert-xls.php";
* }
* })
* }
* -- Html code like this:
*
*
*
*
列标题 *
列标题 *
列标题 *
*
*

