程序员必备之:Excel二维表数据转SELECT CASE 工具
程序员文章站
2022-06-14 15:24:39
...
功能说明:
程序员用二维表转Excel二维表数据转SELECT CASE 工具等。
操作步骤:
1. 复制Excel二维结构表到上边文本框。
2. 提交得到:asp php js三种语言的switch case。
备注说明:
1. 复制数据:首行列标题,以后一行一条数据。
2. 列标题得是英文,因为程序语言都是英文。
<%
sfzhs=request.form("name")
names=sfzhs
title="程序员必备之:Excel二维表数据转SELECT CASE 工具"
%><!doctype html>
<html lang="zh-CN">
<head>
<meta charset="gb2312" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title><%=title%>,96448.cn</title>
<meta name="author" content="yujianyue, [email protected]">
<meta name="copyright" content="www.12391.net">
<style>
*{margin:0;padding:0;font-size:14px;line-height:150%;font-family:"microsoft yahei",SimHei;}
body,html{height:100%;text-align:center;overflow:hidden;background-color:#d0d0d0;}
.html{height:100%;width:100%;position:relative;overflow-y:auto;overflow-x:hidden;}
strong{color:red;}
span{color:green;}
a{color:blue;text-decoration:none;}
a:hover {text-decoration:none;color:green;}
.r {text-align:right;width:30%;}
.l {text-align:left;color:green;}
h3 {color:green;font-size:18px;}
.simg{width:50%;min-width:88px;max-width:188px;}
#divs{margin:0 auto;min-height:98%;position:relative;box-sizing:border-box;}
.divs{width:100%;max-width:1200px;min-width:300px;background-color:#F0F0F0;}
strong{color:red;}
.head{position:fixed;top:0px;margin:0 auto;width:100%;max-width:1200px;min-width:300px;z-index:10;display:block;}
#head{line-height:180%;background-color:#0180CF;font-size:16px;line-height:40px;color:white;}
.back{position:absolute;right:9px;top:0px;line-height:40px;}
.d {border:1px white solid;line-height:150%;color:white;font-size:12px;padding:3px 5px;}
.d:hover {text-decoration:none;background-color:white;color:#0180CF; }
#main{margin:2px auto;padding:30px 1px;width:100%;}
form{margin:24px 0;text-align:left;}
.so_box{margin:10px auto;height:40px;line-height:40px;background-color:white;width:92%;border:1px #CACACA solid;margin-top:12px;position:relative}
.so_bax{margin:10px auto;height:360px;line-height:120%;background-color:white;width:92%;border:1px #CACACA solid;margin-top:12px;position:relative}
.so_box .txts{margin:0px auto;outline: none;line-height:31px;width:88%;padding-left:10px;border:0px;color:#333333;background-color:#FFFFFF;overflow:hidden;}
.so_box .buts{margin:0 auto;height:40px;line-height:40px;width:100%;padding-left:10px;border:0px;color:#333333;background:#0180CF url(line_bg.jpg) repeat-x;border-radius:25px;}
.so_box .more{position:absolute;position:absolute; top:8px; right:10px;}
.so_box .more img{ height:24px;}
textarea{width:100%;min-height:368px;}
@media screen and (max-width: 654px) {
table{border:0;border-top:0px solid #0180CF;}
table thead {display:none;}
table tr{margin-bottom:18px;display:block;border-top:2px solid #0180CF;}
table tr{border-bottom:1px solid #0180CF;}
table td {display:block;text-align:right;font-size:13px;}
table td {border-left:1px dotted #0180CF;border-bottom: 1px dotted #ccc;}
table td:last-child {border-bottom:0;}
table td:before {content:attr(data-label);float:left;text-transform:uppercase;}
table td:before {color:blue;}
}
.table{margin:0 auto;font-size:10px;width:92%;height:300px;}
table{border-left:1px solid #a2c6d3;border-top:3px solid #0180CF; margin:0 auto;font-size:12px;width:92%;}
table td{border-right:1px solid #a2c6d3;border-bottom:1px solid #a2c6d3;padding:5px;word-wrap:break-word;word-break:break-all;}
.tt{background:#e5f2fa;line-height:18px;FONT-SIZE:12px;max-width:596px;}
.select select{width:100%;padding:5px;border:1px #CACACA solid;height:40px;-webkit-appearance:none;}
.select option{height:40px;}
.select{margin:0 auto;width:92%;height:40px;overflow:hidden;}
.so_but{margin:15px auto;width:92%;text-align:center;margin-top:12px;border:0px;}
.so_bus{margin:15px auto;width:92%;text-align:left;margin-top:12px;border:0px;}
.so_but .buts{line-height:200%;padding:5px 25px;background:#0180CF url(line_bg.jpg) repeat-x;border-radius:25px;color:white;border:0px;}
#boto{margin:0 auto;width:100%;max-width:1200px;min-width:300px;position:fixed;bottom:0px;display:block;}
.boto{background-color:#ADADAD;color:#000;text-shadow: 0 1px 1px #fff;line-height:180%;}
</style>
<script language="javascript">
var $=function(node){
return document.getElementById(node);
}
function $(objId){
return document.getElementById(objId);
}
function inst() {
}
function st(ids,Num){
if ($(ids).value == ""){
$(ids).value = '';
}
}
function sr(ids,Num){
if ($(ids).value == ""){
return false;
}else{
}
}
function sta(Num) {
if(Num == 2 || Num == 0){
if($("name")!=null){
if ($("name").value==""){
$('t2').style.borderColor='red';
return false;
}else{
$('t2').style.borderColor='green';
}
}
}
if(Num == "0"){
//return false;
}
}
</script>
</head>
<body>
<div class="html">
<div class="divs" id="divs">
<div id="head" class="head" onclick="location.href='?t=<%=time3%>';">
<%=title%>
<div class="back" id="pageback">
<a href="?t=<%=time2%>" class="d">更多</a>
</div>
</div>
<div class="main" id="main">
<%if len(sfzhs)=0 then%>
<form name="qu" method="post" action="?t=<%=time2%>" onsubmit="return sta(0);">
<div class="so_bax" id="t2">
<textarea name="name" class="txts" id="name" placeholder="复制Excel二维表至此处" onfocus="st('name',2)" onBlur="sta(2)" >
id areaid name parent fl
2 340800 安庆 340000 A
3 340300 蚌埠 340000 B
4 341600 亳州 340000 B
5 341700 池州 340000 C
6 341100 滁州 340000 C
7 341400 巢湖 340000 C
8 341200 阜阳 340000 F
9 340400 淮南 340000 H
10 340100 合肥 340000 H
</textarea>
</div>
<div class="so_but">
<input type="submit" name="button" class="buts" id="sub" value="立即转化" />
<input type="button" class="buts" value="刷新本页" name="print" onclick="location.reload();">
</div>
<div class="so_bus" id="tishi">
<!---你的其他说明在这里添加:开始-->
<h3>功能说明:</h3>
<strong>程序员用</strong>二维表转<span>Excel二维表数据转SELECT CASE 工具</span>等。<br>
<h3>操作步骤:</h3>
1. 复制Excel二维结构表到上边文本框。<br>
2. 提交得到:asp php js三种语言的switch case。<br>
<h3>备注说明:</h3>
1. 复制数据:首行列标题,以后一行一条数据。<br>
2. 列标题得是英文,因为程序语言都是英文。<br>
<!--你的其他说明在这里添加:结束-->
</div>
<div id="tishi1" style="display:none;">请输入周岁计算时间</div>
<div id="tishi2" style="display:none;">复制Excel二维表至此处/div>
<div id="timenow" style="display:none;"><%=time2%></div>
</form>
<%else%>
<p align="center"><span> </span></p>
<p align="center"><span color="red">相关说明:</span> 点本页顶部蓝条白字可返回;</p>
<%
sfzh=split(names,vbcrlf)
snum=ubound(sfzh)
line1=sfzh(0)
titis=split(line1,vbtab)
asptxt = "<% "&vbcrlf&" "&titis(0)&" = ""某某值"" "&vbcrlf&" SELECT CASE "&titis(0)&vbcrlf
phptxt="<?php"&vbcrlf&" $"&titis(0)&" =""某某值""; "&vbcrlf&"switch ($"&titis(0)&") {"&vbcrlf
jsstxt = ""&vbcrlf&"var "&titis(0)&"=""某某值"";"&vbcrlf&" switch ("&titis(0)&") {"&vbcrlf
for xf=1 to snum
aaa=sfzh(xf)
if instr(aaa,vbtab)>0 then
bbb=split(aaa,vbtab)(0)
'ccc=split(aaa,vbtab)(1)
ddd=split(aaa,vbtab)
did=ubound(ddd)
asptxt = asptxt & vbcrlf &"CASE """&bbb&""""&vbcrlf
phptxt = phptxt & vbcrlf &"case """&bbb&""":"&vbcrlf
jsstxt = jsstxt & vbcrlf &"case '"&bbb&"':"&vbcrlf
txtasp = "Response.Write """" "
txtphp = "echo """" "
txtjss = "document.getElementById(""demo"").innerHTML= """" "
for i0=1 to did
txtasp = txtasp& " & "&titis(i0)&" "
txtphp = txtphp& " . $"&titis(i0)&" "
txtjss = txtjss& " + "&titis(i0)&" "
asptxt = asptxt & ""&titis(i0)&" = """&ddd(i0)&""""&vbcrlf
phptxt = phptxt & "$"&titis(i0)&" = """&ddd(i0)&"""; "&vbcrlf
jsstxt = jsstxt & ""&titis(i0)&" = """&ddd(i0)&"""; "&vbcrlf
next
if xf=1 then
myval = bbb
asptxt = replace(asptxt,"某某值",bbb)
phptxt = replace(phptxt,"某某值",bbb)
jsstxt = replace(jsstxt,"某某值",bbb)
end if
phptxt = phptxt & "break;"&vbcrlf
jsstxt = jsstxt & "break;"&vbcrlf
end if
next
asptxt = asptxt & vbcrlf &"CASE ELSE"&vbcrlf
asptxt = asptxt & "Response.Write ""No case :"&bbb&""""&vbcrlf
asptxt = asptxt & "END SELECT "&vbcrlf &" "&vbcrlf
asptxt = asptxt & txtasp &vbcrlf &" %>"&vbcrlf
phptxt = phptxt & vbcrlf &"default:"&vbcrlf
phptxt = phptxt & "exit(""查无此人"");"&vbcrlf
phptxt = phptxt & "}"&vbcrlf &" "&vbcrlf
phptxt = phptxt & txtphp&"; ?>"&vbcrlf
jsstxt = jsstxt & vbcrlf &"default:"&vbcrlf
jsstxt = jsstxt & "alert(""这里改为默认值"");"&vbcrlf
jsstxt = jsstxt & "} "&vbcrlf &vbcrlf
jsstxt = jsstxt & txtjss&";" &vbcrlf
'Response.Write asptxt &vbcrlf &vbcrlf
'Response.Write phptxt &vbcrlf &vbcrlf
'Response.Write "<script type=""text/javascript"">" &vbcrlf
'Response.Write jsstxt
'Response.Write "</script>" &vbcrlf
%>
<%
Response.Write "<table cellspacing=""0"">"&vbcrlf
Response.Write "<thead><tr class=""tt"" onclick=""location.href='?t="&time2&"';"">"&vbcrlf
Response.Write "<td align=""center"" >asp 代码</td>"&vbcrlf
Response.Write "<td align=""center"">php 代码</td>"&vbcrlf
Response.Write "<td align=""center"">js 代码</td>"&vbcrlf
Response.Write "</tr></thead><tbody>"&vbcrlf
Response.Write "<tr>"&vbcrlf
Response.Write "<td data-label=""asp代码""><textarea id=""asp"" class=""txts"">"&vbcrlf
Response.Write asptxt &vbcrlf &vbcrlf
Response.Write "</textarea></td>"&vbcrlf
Response.Write "<td data-label=""php代码""><textarea id=""php"" class=""txts"">"&vbcrlf
Response.Write phptxt &vbcrlf &vbcrlf
Response.Write "</textarea></td>"&vbcrlf
Response.Write "<td data-label=""js代码""><textarea id=""js"" class=""txts"">"&vbcrlf
Response.Write "<div id=""demo""></div>" &vbcrlf
Response.Write "<script type=""text/javascript"">" &vbcrlf
Response.Write jsstxt
Response.Write "</script>" &vbcrlf
Response.Write "</textarea></td>"&vbcrlf
Response.Write "</tr>"&vbcrlf
Response.Write "</tbody></table>"&vbcrlf
%>
<p align="center"><a href="?t=<%=time2%>" id="sube" title="返回">返 回</a></p>
<%end if%>
</div>
<div class="boto" id="boto">
©2018 <a href="http://add.yichaxin.com/?<%=time2%>" target="_blank">就来试试吧(sfz.96448.cn)</a>
</div>
</div>
</div>
</body>
</html>
上一篇: 浅谈Ajax的缓存机制