PowerApps 中的 SaveData 和 LoadData 函数SaveData and LoadData functions in PowerApps

保存并重新加载集合Saves and re-loads a collection.


SaveData 函数会存储某个集合,以便在将来通过另一个名称来使用。The SaveData function stores a collection for later use under a name.

LoadData 函数使用此前通过 SaveData 保存的名称重新加载集合。The LoadData function re-loads a collection by name that was previously saved with SaveData. 不能使用此函数加载另一个源的集合。You can't use this function to load a collection from another source.

LoadData 不创建集合;此函数仅填充现有集合。LoadData doesn't create the collection; the function only fills an existing collection. 必须先通过 Collect 使用正确的创建集合。You must first create the collection with the correct columns by using Collect.

存储经过加密,位于本地设备上的专用位置,与其他用户和其他应用隔离。Storage is encrypted and in a private location on the local device, isolated from other users and other apps.


SaveData( Collection, Name )SaveData( Collection, Name )
LoadData( Collection, Name [, IgnoreNonexistentFile ])LoadData( Collection, Name [, IgnoreNonexistentFile ])

  • Collection - 必需。Collection - Required. 要存储或加载的集合。Collection to be stored or loaded.
  • Name - 必需。Name - Required. 存储的名称。Name of the storage. 必须使用同一名称来保存和加载同一数据集。You must use the same name to save and load the same set of data. 命名空间不与其他应用或用户共享。The name space isn't shared with other apps or users.
  • IgnoreNonexistentFile - 可选。IgnoreNonexistentFile - Optional. 指明 LoadData 函数在找不到匹配文件时是应显示还是应忽略错误的布尔值 (true/false)。Boolean (true/false) value that indicates whether LoadData function should display or ignore errors when it can't locate a matching file. 如果指定“false”,将显示错误。If you specify false, errors will be displayed. 如果指定“true”,将忽略错误,这适用于脱机方案。If you specify true, errors will be ignored, which is useful for offline scenarios. 如果设备处于脱机状态(即,“Connection.Connected”状态为“false”),SaveData 可能会创建文件。SaveData may create a file if the device is offline (that is, if the Connection.Connected status is false).


公式Formula 说明Description 结果Result
If(Connection.Connected, ClearCollect(LocalTweets, Twitter.SearchTweet("PowerApps", {maxResults: 100})),LoadData(LocalTweets, "Tweets", true))If(Connection.Connected, ClearCollect(LocalTweets, Twitter.SearchTweet("PowerApps", {maxResults: 100})),LoadData(LocalTweets, "Tweets", true)) 如果设备处于联机状态,将从 Twitter 服务加载“LocalTweets”集合;否则,将从本地文件缓存加载集合。If the device is connected, load the LocalTweets collection from the Twitter service; otherwise, load the collection from the local file cache. 无论设备处于联机状态还是脱机状态,内容都会呈现。The content is rendered whether the device is online or offline.
SaveData(LocalTweets, "Tweets")SaveData(LocalTweets, "Tweets") 将“LocalTweets”集合另存为设备上的本地文件缓存。Save the LocalTweets collection as a local file cache on the device. 数据会进行本地保存,以便 LoadData 可以将其加载到集合中。Data is saved locally so that LoadData can load it into a collection.