WPF 通过FarPoint显示Excel
Posted 风雨丛中住着一只南飞的雁,
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WPF 通过FarPoint显示Excel相关的知识,希望对你有一定的参考价值。
1、FarPoint 只支持winform,在Wpf中要引用:WindowsFormsIntegration.dll
2、*.xaml文件引用
xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:farpoint="clr-namespace:FarPoint.Win.Spread;assembly=FarPoint.Win.Spread"
--
<wfi:WindowsFormsHost Name="windowsFormsHost1">
<farpoint:FpSpread x:Name="fitnessSpread" />
</wfi:WindowsFormsHost>
3、后台加载Excel模板,
private void LoadFarPoint() { fitnessSpread.OpenExcel(System.Environment.CurrentDirectory + @"\DataTemplates\FarPoint.xlsx"); fitnessSpread.ActiveSheet.OperationMode = FarPoint.Win.Spread.OperationMode.ReadOnly; fitnessSpread.TabStripInsertTab = false; fitnessSpread.TabStripPolicy = FarPoint.Win.Spread.TabStripPolicy.Never; fitnessSpread.ActiveSheet.ColumnHeaderVisible = false; fitnessSpread.ActiveSheet.RowHeaderVisible = false; fitnessSpread.ActiveSheet.RowCount = 29; fitnessSpread.ActiveSheet.ColumnCount = 7; fitnessSpread.ActiveSheet.Cells[0, 0].Text = "后台代码填进来的!"; fitnessSpread.ActiveSheet.Cells[3, 0].Text = "喔哦!"; }
以上是关于WPF 通过FarPoint显示Excel的主要内容,如果未能解决你的问题,请参考以下文章