jsp页面table单元格隐藏边框

zouzaidalu 发布于 2013/09/22 15:00
阅读 3K+
收藏 1

如图所示,隐藏第一、二、四行单元格,只保留第三行,求大神指点~~~

jsp代码如下


<%@ page language="java" contentType="text/html; charset=GBK"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd"
>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>出库清单</title>


<script language="javascript">

        function method1(tableid) {//整个表格拷贝到EXCEL中

            var curTbl = document.getElementById(tableid);

            var oXL = new ActiveXObject("Excel.Application"); //创建AX对象excel

            var oWB = oXL.Workbooks.Add(); //获取workbook对象

            var oSheet = oWB.ActiveSheet; //激活当前sheet

            var sel = document.body.createTextRange();

            sel.moveToElementText(curTbl); //把表格中的内容移到TextRange中

            sel.select(); //全选TextRange中内容

            sel.execCommand("Copy"); //复制TextRange中内容

            oSheet.Paste(); //粘贴到活动的EXCEL中

            oXL.Visible = true; //设置excel可见属性

        }

       
        function getXlsFromTbl(inTblId, inWindow) {

            try {

                var allStr = "";

                var curStr = "";

                if (inTblId != null && inTblId != "" && inTblId != "null") {

                    curStr = getTblData(inTblId, inWindow);

                }

                if (curStr != null) {

                    allStr += curStr;

                }
                else {

                    alert("你要导出的表不存在!");

                    return;

                }

                var fileName = getExcelFileName();

                doFileExport(fileName, allStr);

            }
            catch (e) {

                alert("导出发生异常:" + e.name + "->" + e.description + "!");

            }

        }

        function getTblData(inTbl, inWindow) {

            var rows = 0;

            var tblDocument = document;

            if (!!inWindow && inWindow != "") {

                if (!document.all(inWindow)) {

                    return null;

                }
                else {

                    tblDocument = eval(inWindow).document;

                }

            }

            var curTbl = tblDocument.getElementById(inTbl);

            var outStr = "";

            if (curTbl != null) {

                for (var j = 0; j < curTbl.rows.length; j++) {

                    for (var i = 0; i < curTbl.rows[j].cells.length; i++) {

                        if (i == 0 && rows > 0) {

                            outStr += " \t";

                            rows -= 1;

                        }

                        outStr += curTbl.rows[j].cells[i].innerText + "\t";

                        if (curTbl.rows[j].cells[i].colSpan > 1) {

                            for (var k = 0; k < curTbl.rows[j].cells[i].colSpan - 1; k++) {

                                outStr += " \t";

                            }

                        }

                        if (i == 0) {

                            if (rows == 0 && curTbl.rows[j].cells[i].rowSpan > 1) {

                                rows = curTbl.rows[j].cells[i].rowSpan - 1;

                            }

                        }

                    }

                    outStr += "\r\n";

                }

            }

            else {

                outStr = null;

                alert(inTbl + "不存在!");

            }

            return outStr;

        }

        function getExcelFileName() {

            var d = new Date();

            var curYear = d.getYear();

            var curMonth = "" + (d.getMonth() + 1);

            var curDate = "" + d.getDate();

            var curHour = "" + d.getHours();

            var curMinute = "" + d.getMinutes();

            var curSecond = "" + d.getSeconds();

            if (curMonth.length == 1) {

                curMonth = "0" + curMonth;

            }

            if (curDate.length == 1) {

                curDate = "0" + curDate;

            }

            if (curHour.length == 1) {

                curHour = "0" + curHour;

            }

            if (curMinute.length == 1) {

                curMinute = "0" + curMinute;

            }

            if (curSecond.length == 1) {

                curSecond = "0" + curSecond;

            }

            var fileName = "leo_zhang" + "_" + curYear + curMonth + curDate + "_"

+ curHour + curMinute + curSecond + ".csv";

            return fileName;

        }

        function doFileExport(inName, inStr) {

            var xlsWin = null;

            if (!!document.all("glbHideFrm")) {

                xlsWin = glbHideFrm;

            }
            else {

                var width = 6;

                var height = 4;

                var openPara = "left=" + (window.screen.width / 2 - width / 2)

   + ",top=" + (window.screen.height / 2 - height / 2)

   + ",scrollbars=no,width=" + width + ",height=" + height;

                xlsWin = window.open("", "_blank", openPara);

            }

            xlsWin.document.write(inStr);

            xlsWin.document.close();

            xlsWin.document.execCommand('Saveas', true, inName);

            xlsWin.close();

        }

    </script>

<style type="text/css">
.top {
    margin: 0px auto;
    width: 98%;
}

table,td {
    border-collapse: collapse
}

.bottom {
    width: 98%;
    border: #000000 solid;
    border-width: 1px 0px 0px 1px;
    margin: 0px auto;
}

.bottom td {
    border: #000000 solid;
    border-width: 0px 1px 1px 0px;
}
</style>
</head>

<body>


<table class="bottom" id="tableExcel" cellpadding="0" cellspacing="0" >
    <thead class="top">
        <tr align="center">
            <td  colspan=28 ><font size="5">出库清单</font></td>
        </tr>
        <tr>
            <td colspan=28>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;站点:<s:property
                value="zhandianName" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            打印时间:<s:date name="dayinshijian" format="yyyy-MM-dd HH🇲🇲ss" /></td>

        </tr>

        <tr>
            <td nowrap align="center">运单号</td>
            <td nowrap align="center">发货人</td>
            <td nowrap align="center">发货电话</td>
            <td nowrap align="center">货物名称</td>
            <td nowrap align="center">编号</td>
            <td nowrap align="center">收货人</td>
            <td nowrap align="center">收货人电话</td>
            <td nowrap align="center">收货人地址</td>
            <td nowrap align="center">起点</td>
            <td nowrap align="center">终点</td>
            <td nowrap align="center">付货点</td>
            <td nowrap align="center">车号</td>
            <td nowrap align="center">件数</td>
            <td nowrap align="center">体积</td>
            <td nowrap align="center">重量</td>
            <td nowrap align="center">货款</td>
            <td nowrap align="center">垫付</td>
            <td nowrap align="center">运费</td>
            <td nowrap align="center">已付</td>
            <td nowrap align="center">提付</td>
            <td nowrap align="center">回结</td>
            <td nowrap align="center">付款方式</td>
            <td nowrap align="center">保额</td>
            <td nowrap align="center">保费</td>
            <td nowrap align="center">付款方式</td>
            <td nowrap align="center">中转</td>
            <td nowrap align="center">中转费方式</td>
            <td nowrap align="center">中转返款</td>
        </tr>
    </thead>

    <tbody>
        <s:iterator value="rightHuowuxinxiList" status="index" var="current">
            <tr id="<s:property value="#index.index+1"/>">
                <td nowrap align="center"><s:property
                    value="#current.yundanhao" /></td>
                <td nowrap align="center"><s:property value="#current.fahuoren" /></td>
                <td nowrap align="left"><s:property
                    value="#current.fahuorendianhua" /></td>
                <td nowrap align="left"><s:property
                    value="#current.huowumingcheng" /></td>
                <td nowrap align="left"><s:property value="#current.bianhao" /></td>
                <td nowrap align="left"><s:property value="#current.shouhuoren" /></td>
                <td nowrap align="left"><s:property
                    value="#current.shouhuorendianhua" /></td>
                <td nowrap align="left"><s:property
                    value="#current.shouhuorendizhi" /></td>
                <td nowrap align="center"><s:property
                    value="#current.qidianName" /></td>
                <td nowrap align="center"><s:property
                    value="#current.zhongdianName" /></td>
                <td nowrap align="center"><s:property
                    value="#current.fuhuodianName" /></td>
                <td nowrap align="center"><s:property value="#current.chehao" /></td>
                <td nowrap align="right"><s:property value="#current.jianshu" /></td>
                <td nowrap align="right"><s:property value="#current.zongtiji" /></td>
                <td nowrap align="right"><s:property
                    value="#current.zongzhongliang" /></td>
                <td nowrap align="right"><s:property
                    value="#current.daishouhuokuan" /></td>
                <td nowrap align="right"><s:property
                    value="#current.dianfuhuokuan" /></td>
                <td nowrap align="right"><s:property value="#current.yunfei" /></td>
                <td nowrap align="right"><s:property value="#current.yifu" /></td>
                <td nowrap align="right"><s:property value="#current.tifu" /></td>
                <td nowrap align="right"><s:property value="#current.huijie" /></td>
                <td nowrap align="center"><s:property
                    value="#current.fukuanfangshi" /></td>
                <td nowrap align="right"><s:property
                    value="#current.baoxianjine" /></td>
                <td nowrap align="right"><s:property
                    value="#current.baoxianfei" /></td>
                <td nowrap align="center"><s:property
                    value="#current.baofeifangshi" /></td>
                <td nowrap align="right"><s:property
                    value="#current.zhongzhuanfei" /></td>
                <td nowrap align="center"><s:property
                    value="#current.zhongzhuanfeifangshi" /></td>
                <td nowrap align="right"><s:property
                    value="#current.zhongzhuanfankuan" /></td>

            </tr>
        </s:iterator>



        <tr align="left">
            <td colspan=28>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;份数:<s:property
                value="rightRecount.fenshu" />;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 件数:<s:property
                value="rightRecount.jianshu" />;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 货款:<s:property
                value="rightRecount.huokuan" />;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 运费:<s:property
                value="rightRecount.yunfei" /></td>
        </tr>
    </tbody>
</table>


<input type="button" onclick="javascript:method1('tableExcel');"
    value="导出到EXCEL">

</body>
</html>

加载中
0
0
iSea
iSea
这个是html  css的问题哦,扯上jsp干什么 ,还贴这么多代码,直接table给个  border="0",或者css里border:none;
0
我已经报警了
我已经报警了

代码太乱,编辑一下使用语法着色吧

楼主的功能应该是js导出table到xls,然后隐藏某几行

0
xmut
xmut

JSP躺着中枪 


返回顶部
顶部