asp表格编号怎么转换成对应的名称实例

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
1个回答

由于我使用程序生成一个表格,生成出来的表格行和列需要转换一下,如2行3列的表格要转换成3行2列的表格(这只是一个举例,实际过程中表格的行和列是不确定的)。由于生成表格的过程太麻烦,所以不想再去程序只找其生成规律,想通过生成后的表格字符串,直接转换表格的行和列,这样比较方便。下面是我的代码:

< %
str=str&"<table width=""500"" border=""1"" cellspacing=""0"" cellpadding=""0""> "
str=str&"  <tr> "
str=str&"    <td height=""20"" align=""center"">1 </td> "
str=str&"    <td align=""center"">2 </td> "
str=str&"    <td align=""center"">3 </td> "
str=str&"  </tr> "
str=str&"  <tr> "
str=str&"    <td height=""20"" align=""center"">4 </td> "
str=str&"    <td align=""center"">5 </td> "
str=str&"    <td align=""center"">6 </td> "
str=str&"  </tr> "
str=str&"</table> "

response.write str&"<br>" '这里输出原始的表格

str=Replace(str,"  ","")
str=Replace(str," <","<")
str=Replace(str,"<table width=""500"" border=""1"" cellspacing=""0"" cellpadding=""0"">","")
str=Replace(str,"</table>","")
str=Replace(str,"<tr>","")
str=Replace(str,"<td align=""center"">","")
str=Replace(str,"<td height=""20"" align=""center"">","")

str=Replace(str,"</tr>","|")
str=Trim(Replace(str,"</td>",","))

str=Left(str,Len(str)-1)

a=Split(str,"|")
m=UBound(a)
n=0
If m>0 Then
a2=Trim(a(0))
a2=Left(a2,Len(a2)-1)
b=Split(a2,",")
n=UBound(b)
End if
ReDim c(n+1,m+1)

'response.write "m="&m&" X n="&n&"<br>"
For i=0 To m
    a2=Trim(a(i))
 a2=Left(a2,Len(a2)-1)
 b=Split(a2,",")
    For j=0 To UBound(b)
       c(j,i)=Trim(b(j))
 next
Next

str5="<table width=""500"" border=""1"" cellspacing=""0"" cellpadding=""0"" >"
For i=0 To n
   str5=str5&"<tr>"
   For j=0 To m
      str5=str5&"<td align=""center""  height=""20"" >"&c(i,j)&"</td>"
   Next
   str5=str5&"</tr>"
Next
str5=str5&"</table>"

response.write str5 '这里输出转换后的表格
% >


摘自asp编程网


发布于 2020-12-11 18:10
查看更多
外卖券领取

相关问题

支持语音或者文本回复

语音最长一分钟

点击录音开始,最短不低于3秒