码迷,mamicode.com
首页 > Windows程序 > 详细

【WPF】 通过FarPoint显示Excel

时间:2016-05-30 10:02:38      阅读:321      评论:0      收藏:0      [点我收藏+]

标签:


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

标签:

原文地址:http://www.cnblogs.com/oiliu/p/5541382.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!