0
点赞
收藏
分享

微信扫一扫

CSDN展示多样化Markdown表格

千妈小语 2022-01-28 阅读 31

众所周知,基本的Markdown表格语法为:

| ID | 姓名 |
|:----:|:----:|
| 1 | 小明 |
| 2 | 小强 |

效果如下:

ID姓名
1小明
2小强

表格语法不是特别固定,很灵活,也很丰富,比如可以做的复杂一些:

| ID  | 姓名 | 性别  | 年龄 |
|:----|:-------:|----|-------:|
| 1  | 刘彤 | ♀ | 18 |
| 2 | 肖华 | ♂ | 35 |
| 44  | 李建伟 | undefined | 55 |

效果如下:

ID姓名性别年龄
1刘彤18
2肖华35
44李建伟undefined55

如果想定制化表格,可以借助HTML标签实现:

<table border=0 cellpadding=0 cellspacing=0 width=373 style='border-collapse:
 collapse;table-layout:fixed;width:279pt'>
 <col width=86 style='mso-width-source:userset;mso-width-alt:3072;width:65pt'>
 <col width=130 style='mso-width-source:userset;mso-width-alt:4608;width:97pt'>
 <col width=79 style='mso-width-source:userset;mso-width-alt:2816;width:59pt'>
 <col width=78 style='mso-width-source:userset;mso-width-alt:2759;width:58pt'>
 <tr height=18 style='height:13.8pt'>
  <td colspan=2 height=18 class=xl6515568 width=216 style='height:13.8pt;
  width:162pt'>班级信息</td>
  <td rowspan=2 class=xl6515568 width=79 style='width:59pt'>学生ID</td>
  <td rowspan=2 class=xl6515568 width=78 style='width:58pt'>学生姓名</td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl6515568 style='height:13.8pt'>班级ID</td>
  <td class=xl6515568>班级名称</td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl6515568 style='height:13.8pt'>1</td>
  <td class=xl6515568>计算机2001班</td>
  <td class=xl6515568>20200878</td>
  <td class=xl6515568>刘彤</td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl6515568 style='height:13.8pt'>2</td>
  <td class=xl6515568>计算机2002班</td>
  <td class=xl6515568>20200999</td>
  <td class=xl6515568>肖华</td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl6515568 style='height:13.8pt'>3</td>
  <td class=xl6515568>计算机2003班</td>
  <td class=xl6515568>20201254</td>
  <td class=xl6515568>李建伟</td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl6515568 style='height:13.8pt'>4</td>
  <td class=xl6515568>计算机2004班</td>
  <td class=xl6515568>20201777</td>
  <td class=xl6515568>王冰</td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl6515568 style='height:13.8pt'>5</td>
  <td class=xl6515568>计算机2004班</td>
  <td class=xl6515568>20204567</td>
  <td class=xl6515568>张彬</td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl6515568 style='height:13.8pt'>6</td>
  <td class=xl6515568>计算机2004班</td>
  <td class=xl6515568>20206743</td>
  <td class=xl6515568>赵远</td>
 </tr>
</table>

效果如下:

班级信息学生ID学生姓名
班级ID班级名称
1计算机2001班20200878刘彤
2计算机2002班20200999肖华
3计算机2003班20201254李建伟
4计算机2004班20201777王冰
5计算机2004班20204567张彬
6计算机2004班20206743赵远

实现该效果可以通过Excel实现,即Excel生成对应表格后,选中对应区域,另存为html文件,再从html中取出对应的<table></table>标签内的内容加以微调即可。

举报

相关推荐

0 条评论