使用JavaScript将复杂表格导出为Excel计算机等级考试

文章作者 100test 发表时间 2010:01:01 12:18:44
来源 100Test.Com百考试题网


  使用JavaScript将表格导出为Excel文件是一种比较常见的导出方法,但复杂表格的导出比较麻烦(比如报表的导出),为此我专门写了一段代码专门处理表格导出,与各位分享一下。
  util.js:
  /**
  * Utilities for exporting a table as an excel file
  * @version 0.6
  */
  var idTmr = "".
  function Cleanup() {
  window.clearInterval(idTmr).
  CollectGarbage().
  }
  function exportAsXls(table) {
  function ImpactedCell(row, col, offset) {
  this.row = row.
  this.col = col.
  this.offset = offset.
  }
  function CurrentCell(row, col, text, colspan, rowspan) {
  this.row = row.
  this.col = col.
  this.text = text.
  this.colspan = colspan.
  this.rowspan = rowspan.
  this.getRow = function getRow() {
  return this.row.
  }
  this.setRow = function setRow(row) {
  this.row = row.
  }
  this.getCol = function getCol() {
  return this.col.
  }
  this.setCol = function setCol(col) {
  this.col = col.
  }
  this.setColspan = function setColspan(colspan) {
  this.colspan = colspan.
  }
  this.getColspan = function getColspan() {
  return this.colspan.
  }
  this.setRowspan = function setRowspan(rowspan) {
  this.rowspan = rowspan.
  }
  this.getRowspan = function getRowspan() {
  return this.rowspan.
  }
  }
  function CellManager(originalRow, colOffset, impactedCells, currentCell) {
  this.originalRow = originalRow.
  this.colOffset = colOffset.
  this.impactedCells = impactedCells.
  this.currentCell = currentCell.
  this.setCurrentCell = function setCurrentCell(currentCell) {
  this.currentCell = currentCell.
  }
  this.setOriginalRow = function setOriginalRow(originalRow) {
  this.originalRow = originalRow.
  }
  this.getCorrectedCol = function getCorrectedCol() {
  return this.currentCell.getCol() this.colOffset.
  }

相关文章


打造Tomcat安全启动帐号计算机等级考试
Javascript和JSP标签在页面动态生成树计算机等级考试
Tomcat下JSP、Servlet和JavaBean环境配置计算机等级考试
日期类加减及Java中日期类操作算法大全计算机等级考试
使用JavaScript将复杂表格导出为Excel计算机等级考试
JSP结合XML XSLT将输出转换HTML计算机等级考试
Java优化编程:内存管理计算机等级考试
计算机二级辅导:Java运行时多态性的实现计算机等级考试
计算机二级java辅导:收集的正则表达式计算机等级考试
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛