日期:2014-05-17  浏览次数:20982 次

Efs Frame框架导入,导出Excel
求高手指点Efs Frame框架导入,导出Excel。希望回复时可以给代码加上注释,谢谢了!

------解决方案--------------------
这是我写的一个js导出EfsFrame框架excel方法 只需要传入grid的id即可

JScript code
function doOut(gridid) {

        var gView = Efs.getExt(gridid).getView(); 
        var rows = gView.getRows().length; //行数
        var columncount = Efs.getExt(gridid).getColumnModel().getColumnCount(); //列数
        var r = 1;
        if (gView.getHeaderCell(1).innerText == " ") {
            r = 2;
        }
        try
        {
        var oXL = new ActiveXObject("Excel.Application");
        //创建AX对象excel 
        var oWB = oXL.Workbooks.Add();
        //获取workbook对象 
        var oSheet = oWB.ActiveSheet;
        //激活当前sheet
        catch(e){ 
            alert("创建excel对象失败,请确认已经安装了excel软件!"); 
            return false; 
        } 

        var i = r;
        for (var j= 1; i < columncount; j++,i++) {
            oSheet.Cells(1, j).value = gView.getHeaderCell(i).innerText;
        }
        for (var k = 0, l = 2; k < rows; k++, l++) {
            i = r;
            for (var x = 1; i < columncount; x++, i++) {
                var y = gView.getCell(k, i).firstChild.innerHTML;
                if (y == null || y == "&nbsp;") {
                    y = "";
                }
                oSheet.Cells(l, x).value = "'"+y;
            }
        }
        oXL.Visible = true;
        oXL.Quit();
        oXL = null;
    }