如何使用Power Automate从Dataverse创建Excel行?

发布于 2025-01-18 16:00:56 字数 231 浏览 6 评论 0原文

有人可以将我指向如何使用Power Automate从Dataverse表创建Excel行的教程吗?例如,我有一个数据词表,其中一列之一是“颜色”。对于“蓝色”的每个记录,我都想在Excel文件中添加一行。我很难找到解释这一点的YouTube或博客,但是我敢肯定我的搜索不够好。

我试图连接到Dataverse表,但不确定如何通过所有行循环。也不完全了解数据滤波器中的所有命令,我习惯了powerApps滤波器,但习惯了等式和NE等。

Can someone point me to a tutorial of how to create Excel rows from a Dataverse table using Power Automate? For example, I have a Dataverse table with one of the columns being "color". For every record with "blue", I want to add a row to an Excel file. I'm having a hard time finding a youtube or blog that explains this but I'm sure I'm just not searching well enough.

I've tried to connect to a Dataverse table but not sure how to loop it through all the rows. Also don't quite understand all the commands in the Dataverse filter, I'm used to PowerApps filters but getting used to eq and ne, etc..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自在安然 2025-01-25 16:00:56

有很多方法可以实现您想要的结果。我采用了一种相对简单的方法,该方法应该可以完成您想要的操作,但取决于性能等。您可能想将其更改为其他方法。

首先,我在 DataVerse 中创建了一个表,其中包含一些虚拟字段,显然,您只需要使用自己的表即可。

这是表格的结构,以便您了解上下文,我突出显示了我想要提取的其他字段(以及 ID、名称和创建时间)...

Table

现在在我的流程中,我'已经添加了数据宇宙 ->列出行操作。具体来说,我已根据您的场景将数据过滤到 blue 值的 cr160_color 列中,正如您所希望的那样。

列出行

下一步涉及遍历从表中检索的数据并将其写入 SharePoint 工作区上的 Excel 文档,该工作区具有(必须定义为表),其中以下字段。

电子表格

这是流程中的操作步骤...

向表添加行

当它执行时,我得到我的数据...

Result

如果您运行再次流动,一切都会加倍因此,如果您需要在再次加载之前清除表(如果您觉得麻烦,您可以随时尝试更新或增量加载),那么您可以在加载数据之前插入一个步骤来清除表。

您可以使用 Office 脚本来做到这一点。为此,在 Excel Online 中,功能区中应有一个名为 自动化 的选项卡 ...

Ribbon

在那里,创建一个新脚本,将其命名为清除表数据< /strong> 并添加此代码...

function main(workbook: ExcelScript.Workbook, worksheetName: string, tableName: string)
{
  let worksheet = workbook.getWorksheet(worksheetName);
  let tableToClear = worksheet.getTable(tableName);

  let rowsToDelete = tableToClear.getRangeBetweenHeaderAndTotal().getRowCount();
  
  try {
    tableToClear.deleteRowsAt(0, rowsToDelete - 1);
  }
  catch { }
}

现在,在将所有数据加载回 ...

删除行数据

这是最终流程...

Flow

There are quite a few ways to achieve the result you want. I've gone for a relatively easy approach and one that should do what you want but depending on performance, etc. you may want to change it out for something else.

Firstly, I created a table in DataVerse with a few dummy fields, obviously, you just need to use your own table.

Here's the structure of the table so you have context and I've highlighted the additional fields that I want to pull out (along with the ID, Name and Created On) ...

Table

Now in my flow, I've added the Dataverse -> List rows action. Specifically, I have filtered the data to the cr160_color column for the value blue as you want to do based on your scenario.

List rows

The next step involves traversing the data retrieved from the table and writing it out to an Excel document on a SharePoint workspace that has a table (must be defined as a table) with the following fields.

Spreadsheet

This is the action step in the flow ...

Add rows to table

When it executes, I get my data ...

Result

If you run the flow again, it will double up all of the data so if you need to clear the table before loading again (you could always try updating or delta loading if you can be bothered) then you can inject a step before the loading of the data to clear the table.

You can do that with an office script. To do that, in Excel online, you should have a tab in the ribbon called Automate ...

Ribbon

In there, create a new script, call it Clear Table Data and add this code ...

function main(workbook: ExcelScript.Workbook, worksheetName: string, tableName: string)
{
  let worksheet = workbook.getWorksheet(worksheetName);
  let tableToClear = worksheet.getTable(tableName);

  let rowsToDelete = tableToClear.getRangeBetweenHeaderAndTotal().getRowCount();
  
  try {
    tableToClear.deleteRowsAt(0, rowsToDelete - 1);
  }
  catch { }
}

Now inject that step in your flow before it loads all of the data back in ...

Delete Row Data

This is the final flow ...

Flow

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文