2024-10-14 08:41:15 +08:00
|
|
|
|
<Page
|
|
|
|
|
|
x:Class="ExcelHelper.Views.Pages.ImportExcelPage"
|
|
|
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
|
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
2024-10-21 15:21:17 +08:00
|
|
|
|
xmlns:converter="clr-namespace:ExcelHelper.Converter"
|
2024-10-14 08:41:15 +08:00
|
|
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
|
|
|
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
|
|
|
|
|
xmlns:local="clr-namespace:ExcelHelper.Views.Pages"
|
|
|
|
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
2024-10-21 15:21:17 +08:00
|
|
|
|
xmlns:utils="clr-namespace:ExcelHelper.Utils"
|
2024-10-14 08:41:15 +08:00
|
|
|
|
xmlns:viewmodels="clr-namespace:ExcelHelper.Views.ViewModels"
|
|
|
|
|
|
Title="ImportExcelPage"
|
|
|
|
|
|
d:DataContext="{d:DesignInstance Type=viewmodels:ImportViewModel}"
|
|
|
|
|
|
d:DesignHeight="450"
|
|
|
|
|
|
d:DesignWidth="1200"
|
|
|
|
|
|
mc:Ignorable="d">
|
|
|
|
|
|
<Page.Resources>
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
|
|
|
|
|
<converter:ReBooleanToVisibilityConverter x:Key="ReBooleanToVisibilityConverter" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
<DataTemplate x:Key="Mask">
|
|
|
|
|
|
<Grid Background="#99424242">
|
|
|
|
|
|
<TextBlock
|
|
|
|
|
|
HorizontalAlignment="Center"
|
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
|
FontSize="20"
|
|
|
|
|
|
Foreground="White"
|
|
|
|
|
|
Text="拖拽到此处放开" />
|
2024-10-21 15:21:17 +08:00
|
|
|
|
|
|
|
|
|
|
</Grid>
|
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
|
<DataTemplate x:Key="LoadingMask">
|
|
|
|
|
|
<Grid Background="#99424242">
|
|
|
|
|
|
<hc:CircleProgressBar
|
|
|
|
|
|
HorizontalAlignment="Center"
|
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
|
FontSize="20"
|
|
|
|
|
|
Foreground="White"
|
|
|
|
|
|
IsIndeterminate="True"
|
|
|
|
|
|
Text="加载中" />
|
|
|
|
|
|
|
2024-10-14 08:41:15 +08:00
|
|
|
|
</Grid>
|
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
|
</Page.Resources>
|
|
|
|
|
|
<Grid
|
|
|
|
|
|
AllowDrop="True"
|
|
|
|
|
|
DragEnter="Grid_DragEnter"
|
|
|
|
|
|
DragLeave="Grid_DragLeave"
|
|
|
|
|
|
Drop="Grid_Drop">
|
|
|
|
|
|
<Grid.ColumnDefinitions>
|
|
|
|
|
|
<ColumnDefinition Width="*" MinWidth="800" />
|
|
|
|
|
|
<ColumnDefinition Width="370" MinWidth="370" />
|
|
|
|
|
|
</Grid.ColumnDefinitions>
|
|
|
|
|
|
<ContentPresenter
|
|
|
|
|
|
x:Name="DropFileMask"
|
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
|
Grid.ColumnSpan="2"
|
|
|
|
|
|
Panel.ZIndex="10"
|
2024-10-21 15:21:17 +08:00
|
|
|
|
Content="{Binding}"
|
2024-10-14 08:41:15 +08:00
|
|
|
|
ContentTemplate="{StaticResource Mask}"
|
|
|
|
|
|
Visibility="Collapsed" />
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<ContentPresenter
|
|
|
|
|
|
x:Name="LoadingMask"
|
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
|
Grid.ColumnSpan="2"
|
|
|
|
|
|
Panel.ZIndex="10"
|
|
|
|
|
|
Content="{Binding}"
|
|
|
|
|
|
ContentTemplate="{StaticResource LoadingMask}"
|
|
|
|
|
|
Visibility="{Binding IsLoading, Converter={StaticResource Boolean2VisibilityConverter}}" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
<hc:TabControl Grid.Column="0" Margin="5,5,7,5">
|
|
|
|
|
|
<hc:TabItem Header="预览">
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<DataGrid
|
|
|
|
|
|
x:Name="ExcelDataPreviewGrid"
|
|
|
|
|
|
hc:DataGridAttach.ShowRowNumber="True"
|
|
|
|
|
|
AutoGenerateColumns="False"
|
|
|
|
|
|
EnableColumnVirtualization="True"
|
|
|
|
|
|
EnableRowVirtualization="True"
|
|
|
|
|
|
IsReadOnly="True"
|
|
|
|
|
|
ItemsSource="{Binding ExcelData, IsAsync=True}"
|
|
|
|
|
|
ScrollViewer.CanContentScroll="True"
|
|
|
|
|
|
VirtualizingPanel.IsContainerVirtualizable="True"
|
|
|
|
|
|
VirtualizingPanel.IsVirtualizing="True"
|
|
|
|
|
|
VirtualizingPanel.VirtualizationMode="Recycling" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
</hc:TabItem>
|
|
|
|
|
|
<hc:TabItem Header="列信息">
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<DataGrid
|
|
|
|
|
|
AutoGenerateColumns="False"
|
|
|
|
|
|
IsReadOnly="True"
|
|
|
|
|
|
ItemsSource="{Binding ExcelColumns, IsAsync=True}">
|
|
|
|
|
|
<DataGrid.Columns>
|
|
|
|
|
|
<DataGridTextColumn Binding="{Binding Header}" Header="列" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
</DataGrid.Columns>
|
|
|
|
|
|
</DataGrid>
|
|
|
|
|
|
</hc:TabItem>
|
|
|
|
|
|
</hc:TabControl>
|
|
|
|
|
|
<GridSplitter
|
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
|
Width="2"
|
|
|
|
|
|
Margin="0,5" />
|
|
|
|
|
|
<GroupBox
|
|
|
|
|
|
Grid.Column="1"
|
|
|
|
|
|
Margin="5"
|
|
|
|
|
|
Padding="5">
|
|
|
|
|
|
<GroupBox.Header>
|
|
|
|
|
|
<StackPanel Orientation="Horizontal">
|
|
|
|
|
|
<TextBlock
|
|
|
|
|
|
Margin="5,0"
|
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
|
Text="参数配置" />
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
|
Command="{Binding ReLoadExcelCommand}"
|
|
|
|
|
|
Content="重新读取Excel" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
</StackPanel>
|
|
|
|
|
|
</GroupBox.Header>
|
|
|
|
|
|
<hc:SimpleStackPanel SnapsToDevicePixels="True">
|
|
|
|
|
|
<hc:SimpleStackPanel.Resources>
|
|
|
|
|
|
<Style TargetType="{x:Type hc:SimpleStackPanel}">
|
|
|
|
|
|
<Setter Property="Margin" Value="5,0" />
|
|
|
|
|
|
</Style>
|
|
|
|
|
|
</hc:SimpleStackPanel.Resources>
|
|
|
|
|
|
|
|
|
|
|
|
<hc:SimpleStackPanel Orientation="Horizontal">
|
|
|
|
|
|
<Label Content="指定的Sheet:" />
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<hc:ComboBox
|
|
|
|
|
|
MinWidth="60"
|
|
|
|
|
|
Margin="0"
|
|
|
|
|
|
ItemsSource="{Binding Sheets}"
|
|
|
|
|
|
SelectedValue="{Binding SelectedSheetName}" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
Margin="0"
|
|
|
|
|
|
VerticalAlignment="Center"
|
2024-10-21 15:21:17 +08:00
|
|
|
|
Command=""
|
|
|
|
|
|
Content="读取" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
</hc:SimpleStackPanel>
|
|
|
|
|
|
<hc:SimpleStackPanel Height="Auto" Orientation="Horizontal">
|
|
|
|
|
|
<Label Content="起始位置:" />
|
|
|
|
|
|
<hc:TextBox MinWidth="40" Text="{Binding StartCell}" />
|
|
|
|
|
|
<CheckBox Content="包含列头" IsChecked="{Binding UseHeaderRow}" />
|
|
|
|
|
|
</hc:SimpleStackPanel>
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<hc:SimpleStackPanel IsEnabled="False" Orientation="Horizontal">
|
2024-10-14 08:41:15 +08:00
|
|
|
|
<Label Content="结束位置:" />
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<hc:TextBox MinWidth="40" Text="{Binding EndCell}" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
</hc:SimpleStackPanel>
|
|
|
|
|
|
<hc:SimpleStackPanel Orientation="Horizontal">
|
|
|
|
|
|
<Label Content="最大读取行数:" />
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<hc:NumericUpDown
|
|
|
|
|
|
MinWidth="40"
|
|
|
|
|
|
Minimum="0"
|
|
|
|
|
|
Value="{Binding MaxRow}" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
</hc:SimpleStackPanel>
|
|
|
|
|
|
<hc:SimpleStackPanel Width="Auto" Orientation="Horizontal">
|
|
|
|
|
|
<Label Content="当前文件路径:" />
|
|
|
|
|
|
<!--<hc:TextBox MinWidth="200" />-->
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<hc:ComboBox
|
|
|
|
|
|
MaxWidth="200"
|
|
|
|
|
|
ItemsSource="{Binding ExcelFiles}"
|
|
|
|
|
|
SelectedValue="{Binding CurrentFilePath}" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
</hc:SimpleStackPanel>
|
|
|
|
|
|
<hc:SimpleStackPanel Orientation="Horizontal">
|
|
|
|
|
|
<Label Content="Excel密码:" />
|
2024-10-21 15:21:17 +08:00
|
|
|
|
<PasswordBox MinWidth="60" utils:PasswordBoxHelper.Password="{Binding ExcelPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
2024-10-14 08:41:15 +08:00
|
|
|
|
<Button Content="?" ToolTip="未加密留空,多个Excel如果不同密码请分批次导入" />
|
|
|
|
|
|
</hc:SimpleStackPanel>
|
|
|
|
|
|
</hc:SimpleStackPanel>
|
|
|
|
|
|
|
|
|
|
|
|
</GroupBox>
|
2024-10-21 15:21:17 +08:00
|
|
|
|
|
2024-10-14 08:41:15 +08:00
|
|
|
|
</Grid>
|
|
|
|
|
|
</Page>
|