DSOFramer控件使用注意事項


1.引用dll==>AxInterop.DSOFramer.dll
==>Interop.DSOFramer.dll
==>WindowsFormsIntegration
==>System.Windows.Forms
2.設置嵌入互操作類型為False
引用-->引用的dll(AxInterop.DSOFramer.dll,Interop.DSOFramer.dll)-->屬性-->找到嵌入互操作類型選成False
3.設置項目生成平台x86(不然會報錯)
4.xaml代碼:

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button Height="30" Width="80" x:Name="btn_Open" Click="btn_Open_Click"/>
<WindowsFormsHost Grid.Row="1" x:Name="wfHost" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<dsoFramer:AxFramerControl x:Name="Framer" />
</WindowsFormsHost>
</Grid>

cs代碼

設置屬性:
Framer.Menubar = false;// 
Framer.Titlebar = false;// 隱藏列頭
Framer.Toolbars = false;// 隱藏工具欄
設置打開方法:
private void SetDocment(string filePath)
{
Framer.FrameHookPolicy = dsoFrameHookPolicy.dsoSetOnFirstOpen;
if (String.IsNullOrEmpty(filePath))
return;
try
{
Framer.Select();
Framer.Open(filePath);
}
catch (Exception)
{
MessageBox.Show("打開失敗");
}

this.Dispatcher.BeginInvoke(DispatcherPriority.Background, (DispatcherOperationCallback)delegate(object o)
{
if (Framer != null)
{
Framer.Activate();
}
return null;
}, null);
Framer.Activate();
}
private void btn_Open_Click(object sender, RoutedEventArgs e)
{
SetDocment(AppDomain.CurrentDomain.BaseDirectory + "2016-05-20估值表對賬結果.xlsx");
} 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM