简体   繁体   English

使用 Power Automate 将日期/时间从 Excel 导入 Sharepoint 列表

[英]Importing Dates/Time from Excel to a Sharepoint list using Power Automate

I'm hoping somebody can shed some light on this issue.我希望有人可以对这个问题有所了解。 I am trying to build a flow that adds new entries/updates existing entries in a SP list based on an Excel Spreadsheet stored on OneDrive.我正在尝试构建一个基于 OneDrive 上存储的 Excel 电子表格在 SP 列表中添加新条目/更新现有条目的流。 The spreadsheet contains both columns with dates and date & time.电子表格包含带有日期和日期和时间的两列。 I've researched this extensively, trying to get the dates properly transferred into SP.我对此进行了广泛的研究,试图将日期正确地转移到 SP 中。 The common solution is to use an expression AddDays (for dates) and AddSeconds (for time), as per tutorials here and here .根据此处此处的教程,常见的解决方案是使用表达式 AddDays(用于日期)和 AddSeconds(用于时间)。

However, these methods require the dates and time to be passed as numerical values (integers and float respectively) from Excel.但是,这些方法需要将日期和时间作为数值(分别为整数和浮点数)从 Excel 传递。 It appears that the Excel Online connector only passes those values as string. Excel Online 连接器似乎仅将这些值作为字符串传递。 As discussed in this thread , this used to work with the standard Excel connector, but this connector got deprecated.正如在此线程中所讨论的,这曾经适用于标准 Excel 连接器,但此连接器已被弃用。 I'm hoping somebody has a workaround or solution.我希望有人有解决方法或解决方案。 Thank you!谢谢!

Update: As the SP list expects the date time as string, I've also tried to convert the dates & time columns to text in Excel, using the Text function.更新:由于 SP 列表期望日期时间为字符串,我还尝试使用 Text 函数将日期和时间列转换为 Excel 中的文本。 It worked for transferring the dates, but the time values are inconsistent.它用于传输日期,但时间值不一致。

Declare two variables声明两个变量

  1. StringDate Type: String StringDate类型:String
  2. StrToInt Type: Integer StrToInt类型:整数

变量

Now set "StringDate" to your Excel value.现在将“StringDate”设置为您的 Excel 值。 (Please keep in mind I am using an Apply to Each to get the Excel value) (请记住,我正在使用 Apply to Each 来获取 Excel 值)

字符串日期值

Now convert "StringDate" to an integer with " StrToInt" and Decrement "StrToInt" by 1.现在将“StringDate”转换为带有“StrToInt”的整数,并将“StrToInt”减1。

@{int(variables('StringDate'))}

字符串转整数

Now add the integer to SharePoint and convert it to a date.现在将整数添加到 SharePoint 并将其转换为日期。

@{addDays('1899-12-31',int(variables('StrToInt')),'yyyy-MM-dd')}

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM