• Spread基本知识(一)


    1.FpSpread控件获取当前行号和列号

            With Me.FpSpread1.ActiveSheet
                Dim str As String = String.Format("当前行号 {0} 当前列号 {1}", .ActiveRow.Index, _
                                                                                .ActiveColumn.Index)
                Me.ShowMesage(str)
                str = String.Format("当前行号 {0} 当前列号 {1}", .ActiveRow.Index2, _
                .ActiveColumn.Index2)
                Me.ShowMesage(str)
            End With

    2.FpSpread控件选择单元格时,更改这一行的颜色

          '判断是否点击列头
            If Not e.ColumnHeader Then
                Dim sheet As FarPoint.Win.Spread.SheetView = e.View.Sheets(e.View.ActiveSheetIndex)
    
                Me.ShowMesage(String.Format("共有 {0} 行", sheet.Rows.Count))
    
                sheet.Rows(e.Row).BackColor = Color.Blue
                For i As Integer = 0 To sheet.Rows.Count - 1
                    If i <> e.Row Then
                        sheet.Rows(i).BackColor = sheet.DefaultStyle.BackColor
                    End If
                Next
            End If
    3.FpSpread控件单元格的设置值,获取值
            '获取当前单元格
            If Not Me.FpSpread1.ActiveSheet.ActiveCell Is Nothing Then
                Me.ShowMesage("当前单元格的值 " & Me.FpSpread1.ActiveSheet.ActiveCell.Text)
            End If
    
            '获取指定位置单元格的值
            Dim cell As FarPoint.Win.Spread.Cell = Me.FpSpread1.ActiveSheet.Cells(1, 1)
            Me.ShowMesage("(1,1) 单元格的值 " & cell.Text)
    
            'tag的应用
            cell = Me.FpSpread1.ActiveSheet.Cells(1, 2)
            cell.Tag = "ppome"
    
            cell = Me.FpSpread1.ActiveSheet.Cells("ppome")
            If cell Is Nothing Then
                Me.ShowMesage("按tag 获取单元失败,ppome 不存在")
            Else
                Me.ShowMesage(String.Format("{0},{1} 单元格值 {2}", cell.Row.Index, cell.Column.Index, cell.Text))
            End If
    按tag获取时,如果存在有相同的tag则只返回一个?就近一个吧.
      '设置单元格的值
            If Not Me.FpSpread1.ActiveSheet.ActiveCell Is Nothing Then
                Me.FpSpread1.ActiveSheet.ActiveCell.Text = "http://www.ppome.cn"
            Else
                MessageBox.Show("没有选择单元格.")
            End If
    4.FpSpread控件通过下键选择单元格时时,更改行的颜色
            Dim sheet As FarPoint.Win.Spread.SheetView = Me.FpSpread1.ActiveSheet
            sheet.Rows(e.NewRow).BackColor = Color.Cyan
            For i As Integer = 0 To sheet.Rows.Count - 1
                If i <> e.NewRow Then
                    sheet.Rows(i).BackColor = sheet.DefaultStyle.BackColor
                End If
            Next
  • 相关阅读:
    docker入门
    IAR屏蔽警告的方法
    在MDK 中忽略(suppress) 某一个警告
    stm32 F40x CCM数据区的使用
    如何理解Stand SPI Dual SPI 和Quad SPI??
    stm32F1在sram中调试运行代码
    stm32低功耗的一点总结
    C语言中__attribute__ ((at())绝对定位的应用
    系统栈和任务栈——freertos
    软件模拟spi的注意事项
  • 原文地址:https://www.cnblogs.com/zqonline/p/1353800.html
Copyright © 2020-2023  润新知