添加到从Excel导入的对话框
This commit is contained in:
33
ViewModels/Dialogs/ImportExcelDialogViewModel.cs
Normal file
33
ViewModels/Dialogs/ImportExcelDialogViewModel.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using PMSWPF.Helper;
|
||||
using PMSWPF.Models;
|
||||
|
||||
namespace PMSWPF.ViewModels.Dialogs;
|
||||
|
||||
public partial class ImportExcelDialogViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? _filePath;
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<VariableData> _variableData = new();
|
||||
|
||||
partial void OnFilePathChanged(string? value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var data = ExcelHelper.ImprotFromTiaVariableTable(value);
|
||||
VariableData = new ObservableCollection<VariableData>(data);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
// Handle exception
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user