Power Automate workflow 创建html table 并添加样式

1、获取sharepoint list items (filter Query: key eq 'value')

2、filter 数据筛选 (Filter array)

3、存储数据 (Set variable)

(ps: 存储数据之前需要先初始化数据,并且initialize data只能在workflow top)

4、创建table (Create HTML table)

  1. 向某个column添加a标签:

concat('<a href="', item()?['{Link}'], '" >', item()?['Title'], '</a>')

HTML 表格不允许您添加另一个 HTML 标记,因为它可能会破坏表格。所以插入表格的a标签会以纯文本的形式显示。

我们需要对创建好的table进行编辑

使用表达式,将转义字符替换撑标签

replace(replace(replace(body('Create_HTML_table'),'&lt;','<'),'&gt;','>'),'&quot;','"')

  1. 向创建好的table添加样式

同样使用 Compose Action,使用表达式添加样式(其他样式同理)

replace(body('Create_HTML_table'), '<table>', '<table style="text-align: left;background-color: #f8fcff;border: #ffffff solid 1px;border-collapse: collapse;border: 1;width: 100%;" border="1">')

5、最后send an email 输出Compose之后的数据

补充:

向table中添加样式可以直接用<style>引入,这种方式用起来更简洁灵活,之后修改也一目了然。
<style>
table {
background-color: #f8fcff;
border: #ffffff solid 1px;
border-collapse: collapse;
width: 100%;
}
table thead {
background-color: #dfebf5;
}
table th, td {
  text-align: left;
  padding: 10px 15px;
}
</style>

参考文档:

https://social.technet.microsoft.com/wiki/contents/articles/54489.power-automate-style-the-email-body-with-css.aspx

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值