# YSSpreadSheetView **Repository Path**: yscodingman/spread-sheet-view ## Basic Information - **Project Name**: YSSpreadSheetView - **Description**: Swift-Excel表格 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-05-09 - **Last Updated**: 2024-02-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # YSSpreadSheetView [![CI Status](https://img.shields.io/travis/万孟超/YSSpreadSheetView.svg?style=flat)](https://travis-ci.org/万孟超/YSSpreadSheetView) [![Version](https://img.shields.io/cocoapods/v/YSSpreadSheetView.svg?style=flat)](https://cocoapods.org/pods/YSSpreadSheetView) [![License](https://img.shields.io/cocoapods/l/YSSpreadSheetView.svg?style=flat)](https://cocoapods.org/pods/YSSpreadSheetView) [![Platform](https://img.shields.io/cocoapods/p/YSSpreadSheetView.svg?style=flat)](https://cocoapods.org/pods/YSSpreadSheetView) ## Example To run the example project, clone the repo, and run `pod install` from the Example directory first. ## Requirements ![表格](image.png) ### 初始化 ```Swift lazy var spreadSheetView: YSSpreadSheetView = { let config = YSSpreadSheetViewConfig() config.isShowSectionTitle = true config.isShowItemTitle = true config.sectionHeight = YSSpreadSheetViewConfig.automaticDimension config.estimatedSectionHeight = 44 config.isAverageSheet = false config.totalHighLightCountInView = 8 config.totalHighLightCountInSection = 2 let spread = YSSpreadSheetView(config: config, delegate: self, dataSource: self) return spread }() ``` ### YSSpreadSheetViewDataSource ```Swift @MainActor @objc public protocol YSSpreadSheetViewDataSource: NSObjectProtocol { /// 表格列数,不受`isShowItemTitle`影响 /// - Parameter spreadSheetView: 表格 /// - Returns: 列数 func numberOfItems(in spreadSheetView: YSSpreadSheetView) -> Int /// 表格行数,不受`isShowSectionTitle`影响 /// - Parameter spreadSheetView: 表格 /// - Returns: 行数 func numberOfSections(in spreadSheetView: YSSpreadSheetView) -> Int /// `isShowSectionTitle`为`true`时标题 /// - Parameters: /// - spreadSheetView: 表格 /// - section: 第几行 /// - Returns: 标题Cell @objc optional func spreadSheetView(_ spreadSheetView: YSSpreadSheetView, titleViewForSectionAt section: Int) -> YSSpreadSheetSubView? /// `isShowItemTitle`为`true`时标题 /// - Parameters: /// - spreadSheetView: 表格 /// - item: 第几列 /// - Returns: 标题Cell @objc optional func spreadSheetView(_ spreadSheetView: YSSpreadSheetView, titleViewForItemAt item: Int) -> YSSpreadSheetSubView? /// `section`的高度 /// - Parameters: /// - spreadSheetView: 表格 /// - section: 行 /// - Returns: 高度 @objc optional func spreadSheetView(_ spreadSheetView: YSSpreadSheetView, heightForCellAt section: Int) -> CGFloat /// `item`的宽度 /// - Parameters: /// - spreadSheetView: 表格 /// - item: 列 /// - Returns: 宽度 @objc optional func spreadSheetView(_ spreadSheetView: YSSpreadSheetView, widthForCellAt item: Int) -> CGFloat /// Cell代理 不受`isShowItemTitle,isShowSectionTitle`影响 /// - Parameters: /// - spreadSheetView: 表格 /// - indexPath: 几行几列 /// - Returns: Cell func spreadSheetView(_ spreadSheetView: YSSpreadSheetView, cellAt indexPath: IndexPath) -> YSSpreadSheetSubView /// `section`行可高亮的个数 /// - Parameters: /// - spreadSheetView: 表格 /// - section: 第几行 /// - Returns: 可高亮个数 @objc optional func spreadSheetView(_ spreadSheetView: YSSpreadSheetView, sectionHighLightCountIn section: Int) -> Int /// `item`中可高亮的个数 /// - Parameters: /// - spreadSheetView: 表格 /// - item: 第几列 /// - Returns: 可高亮个数 @objc optional func spreadSheetView(_ spreadSheetView: YSSpreadSheetView, itemHighLightCountIn item: Int) -> Int } ``` ### YSSpreadSheetViewDelegate ```Swift @MainActor @objc public protocol YSSpreadSheetViewDelegate: UIScrollViewDelegate { /// Cell是否可以高亮 /// - Parameters: /// - spreadSheetViewCell: Cell /// - indexPath: 几行几列 /// - Returns: 是否可以高亮 @objc optional func spreadSheetView(_ spreadSheetViewCell: YSSpreadSheetSubView, shouldHighlightAt indexPath: IndexPath) -> Bool /// Cell已经高亮 /// - Parameters: /// - spreadSheetViewCell: Cell /// - indexPath: 几行几列 @objc optional func spreadSheetView(_ spreadSheetViewCell: YSSpreadSheetSubView, didHighlightAt indexPath: IndexPath) /// Cell是否可以取消高亮 /// - Parameters: /// - spreadSheetViewCell: Cell /// - indexPath: 几行几列 /// - Returns: 是否可以取消高亮 @objc optional func spreadSheetView(_ spreadSheetViewCell: YSSpreadSheetSubView, shouldUnHighlightAt indexPath: IndexPath) -> Bool /// Cell已经取消高亮 /// - Parameters: /// - spreadSheetViewCell: Cell /// - indexPath: 几行几列 @objc optional func spreadSheetView(_ spreadSheetViewCell: YSSpreadSheetSubView, didUnHighlightAt indexPath: IndexPath) /// Cell是否可以选中 /// - Parameters: /// - spreadSheetViewCell: Cell /// - indexPath: 几行几列 /// - Returns: 是否可以选中 @objc optional func spreadSheetView(_ spreadSheetViewCell: YSSpreadSheetSubView, shouldSelectItemAt indexPath: IndexPath) -> Bool /// 是否可以取消选中 /// - Parameters: /// - spreadSheetViewCell: Cell /// - indexPath: 几行几列 /// - Returns: 是否可以取消高亮 @objc optional func spreadSheetView(_ spreadSheetViewCell: YSSpreadSheetSubView, shouldDeselectItemAt indexPath: IndexPath) -> Bool /// 选中Cell /// - Parameters: /// - spreadSheetViewCell: Cell /// - indexPath: 几行几列 @objc optional func spreadSheetView(_ spreadSheetViewCell: YSSpreadSheetSubView, didSelectItemAt indexPath: IndexPath) /// 取消选中Cell /// - Parameters: /// - spreadSheetViewCell: Cell /// - indexPath: 几行几列 @objc optional func spreadSheetView(_ spreadSheetViewCell: YSSpreadSheetSubView, deselectItemAt indexPath: IndexPath) } ``` ## Installation YSSpreadSheetView is available through [CocoaPods](https://cocoapods.org). To install it, simply add the following line to your Podfile: ```Swift pod 'YSSheetView' ``` ## Author Wan_CodingMan, wmc912@163.com ## License YSSpreadSheetView is available under the MIT license. See the LICENSE file for more info.