【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 = ;
fitnessSpread.ActiveSheet.ColumnCount = ; fitnessSpread.ActiveSheet.Cells[, ].Text = "后台代码填进来的!";
fitnessSpread.ActiveSheet.Cells[, ].Text = "喔哦!";
}

--属性,

            fitnessSpread.OpenExcel(System.Environment.CurrentDirectory + @"\DataTemplates\FarPoint.xlsx");
fitnessSpread.Sheets[].OperationMode = FarPoint.Win.Spread.OperationMode.ReadOnly; fitnessSpread.TabStripInsertTab = false;
//是否显示sheettab 行
//fitnessSpread.TabStripPolicy = FarPoint.Win.Spread.TabStripPolicy.Never;
//显示列标题
fitnessSpread.Sheets[].ColumnHeaderVisible = false;
//显示行标题
fitnessSpread.Sheets[].RowHeaderVisible = false;
//显示行数
fitnessSpread.Sheets[].RowCount = ;
//显示列数
fitnessSpread.Sheets[].ColumnCount = ;
//sheet名称
fitnessSpread.Sheets[].SheetName = "SheetName";
//表格加数据
fitnessSpread.Sheets[].Cells[, ].Text = "后台代码填进来的!";
fitnessSpread.Sheets[].Cells[, ].Text = "喔哦!";
//初始化sheet显示哪一个
fitnessSpread.ActiveSheetIndex = ;
上一篇:Android SDK Manager更新不了的解决办法


下一篇:odi 12.2.1.1新特性