JXExcel 0.0.3

JXExcel 0.0.3

pujiaxin 维护。



JXExcel 0.0.3

  • pujiaxin33

JXExcel

轻量级的表格视图,类似 Excel!

预览

要求

  • iOS 9.0+
  • XCode 10.2.1+
  • Swift 5.0+

安装

CocoaPods

Target '<Your Target Name>' do
     Pod 'JXExcel'
End

首先执行 pod repo update,然后执行 pod install

使用方法

初始化 ExcelView 对象

        excel = ExcelView(frame: CGRect.zero)
        excel.dataSource = self
        excel.delegate = self
        view.addSubview(excel)

实现 ExcelViewDataSource 接口

    func numberOfRows(in excelView: ExcelView) -> Int {
        return 50
    }

    func numberOfColumns(in excelView: ExcelView) -> Int {
        return 10
    }

    func excelView(_ excelView: ExcelView, columnNameAt column: Int) -> String {
        return "col:\(column)"
    }

    func excelView(_ excelView: ExcelView, rowDataAt row: Int) -> [String] {
        return dataSource[row]
    }

    func excelView(_ excelView: ExcelView, rowHeightAt row: Int) -> CGFloat {
        return 40
    }

    func excelView(_ excelView: ExcelView, columnWidthAt column: Int) -> CGFloat {
        return 120
    }

    func widthOfLeftHeader(in excelView: ExcelView) -> CGFloat {
        return 50
    }

    func heightOfTopHeader(in excelView: ExcelView) -> CGFloat {
        return 40
    }

实现 ExcelViewDelegate 协议

    func excelView(_ excelView: ExcelView, didTapGridWith content: String) {
        print("didTapGridWith:\(content)")
    }

    func excelView(_ excelView: ExcelView, didTapColumnHeaderWith name: String) {
        print("didTapColumnHeaderWith:\(name)")
    }