• 【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 + @"DataTemplatesFarPoint.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 = "喔哦!";
            }

     --属性,

                fitnessSpread.OpenExcel(System.Environment.CurrentDirectory + @"DataTemplatesFarPoint.xlsx");
                fitnessSpread.Sheets[1].OperationMode = FarPoint.Win.Spread.OperationMode.ReadOnly;
    
                fitnessSpread.TabStripInsertTab = false;
                //是否显示sheettab 行
                //fitnessSpread.TabStripPolicy = FarPoint.Win.Spread.TabStripPolicy.Never;
                //显示列标题
                fitnessSpread.Sheets[1].ColumnHeaderVisible = false;
                //显示行标题
                fitnessSpread.Sheets[1].RowHeaderVisible = false;
                //显示行数
                fitnessSpread.Sheets[1].RowCount = 29;
                //显示列数
                fitnessSpread.Sheets[1].ColumnCount = 7;
                //sheet名称
                fitnessSpread.Sheets[0].SheetName = "SheetName";
                //表格加数据
                fitnessSpread.Sheets[1].Cells[0, 0].Text = "后台代码填进来的!";
                fitnessSpread.Sheets[1].Cells[3, 0].Text = "喔哦!";
                //初始化sheet显示哪一个
                fitnessSpread.ActiveSheetIndex = 1;
  • 相关阅读:
    ModelState 错误信息输出
    c# 导入导出excel方法封装
    签名时出错: 未在路径 C:Program Files (x86)Microsoft SDKsWindowsv7.0Ain
    win 10 升级远程连接服务器 要求的函数不受支持
    请求被中止: 未能创建 SSL/TLS 安全通道
    访问iis 出现500.19错误
    ubuntu下交叉编译海思平台下的x264/x265
    C++编程规范
    C++入门--菱形继承与虚继承
    C++入门 --- 纯虚函数与抽象类
  • 原文地址:https://www.cnblogs.com/oiliu/p/5541382.html
Copyright © 2020-2023  润新知