Spreadsheet CollectionViewLayout in Swift. Fully customizable. 🔶

Overview

SwiftSpreadsheet

Version License Platform Swift Package Manager compatible

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Swift 5.0

Installation

SwiftSpreadsheet is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SwiftSpreadsheet"

Demo

Output sample

Quick start

A short introduction on how to get started:

The rows of the spreadsheet represent a section in the collection view, with columns being the respective items. The leftmost and the rightmost elements of the spreadsheet (leftRowHeadline and rightRowHeadline), as well as the topmost and the bottommost elements (topColumnHeader and bottomColumnFooter) are represented as UISupplementaryView, which — if needed — have to be registered with the respective identifiers of the provided enum ViewKindType (refer to the example code).

The corners of the resulting spreadsheet are represented as UIDecorationView which can be passed as UINib or as AnyClass upon initialization of the layout. To allow more flexibilty you have to pass the given nib or class via the DecorationViewType enum. Its cases hold one of the respective types as associative value: asNib(myNib) or asClass(myClass).

A short example:

//Register SupplementaryViews first, then initialize the layout with optional Nibs/Classes for the DecorationViews
let layout = SpreadsheetLayout(delegate: self,
                               topLeftDecorationViewType: .asNib(topLeftDecorationViewNib),
                               topRightDecorationViewType: .asNib(topRightDecorationViewNib),
                               bottomLeftDecorationViewType: .asClass(bottomLeftDecorationViewClass),
                               bottomRightDecorationViewType: .asClass(bottomRightDecorationViewClass))

//Default is true, set false here if you do not want some of these sides to remain sticky
layout.stickyLeftRowHeader = true
layout.stickyRightRowHeader = true
layout.stickyTopColumnHeader = true
layout.stickyBottomColumnFooter = true

self.collectionView.collectionViewLayout = layout

Implement the provided SpreadsheetLayoutDelegate. The methods are straightforward. Simply pass nil wherever you do not want supplementary views to be displayed (leftmost, rightmost, topmost and bottommost).

Reload Layout:

//On Layout:
layout.resetLayoutCache()
//Helper Method for collection view
collectionView.reloadDataAndSpreadsheetLayout()

So in short:

  1. Register the respective objects of type UISupplementaryView you want to use with the provided identifiers of the enum ViewKindType.
  2. Create a UINib object for each UIDecrationView (corner of the Spreadsheet) and pass it upon initialization of the layout.
  3. Initialize the layout with the provided convenience initializer and pass the delegate as well as the required decoration views.
  4. Implement the SpreadsheetLayoutDelegate.
  5. Set the content of your cells and the supplementary views in the data source methods of your collection view.
  6. Enjoy ;)

Questions

Please refer to the demo application or contact me directly.

Author

Wojtek Kordylewski.

indiControl GmbH owns the Copyright of the respective SwiftSpreadsheet.swift file.

License

SwiftSpreadsheet is available under the MIT license. See the LICENSE file for more info.

Comments
  • Add support for registering decoration view classes rather than nibs

    Add support for registering decoration view classes rather than nibs

    UICollectionViewLayout usually supports registering decoration views as both nibs and classes. This change is to allow the SpreadsheetLayout subclass to also provide that functionality.

    opened by swoolcock 4
  • DecorativeView

    DecorativeView

    I'm pretty sure this is a dumb question, but is there a way to update/set the label into a decorative view programmatically ? I didn't find any example about it in the project and I don't understand how I may access to the label in order to change "Revenue" by something else

    Thanks in advance

    opened by bdhaeseleer 3
  • Section header that spans out over multiple columns

    Section header that spans out over multiple columns

    Hello, great work on the library and the fact that it relies on native UICollectionView system is great.

    I'm trying to create "grouped headers" that can span over muliple columns like in the screenshot below. How would you approach it? image

    I was thinking about adding a large section header but the width of headers column is tied to the width of row's columns.

    opened by jbouaziz 2
  • How to change label text of DecorationViews??

    How to change label text of DecorationViews??

    thanks for the awesome library!! I can just create another nib file but I was wondering how to change label text on the fly.. Things I've tried..

    //First I registered decorationview as SupplementaryView

    self.collectionView.register(topRightDecorationViewNib, forSupplementaryViewOfKind: SpreadsheetLayout.ViewKindType.decorationTopRight.rawValue, withReuseIdentifier: self.defaultSupplementaryViewIdentifier)

    //Lastly I tried to access it under ViewKind

    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
            guard let viewKind = SpreadsheetLayout.ViewKindType(rawValue: kind) else { fatalError("View Kind not available for string: \(kind)") }
            
            let supplementaryView = collectionView.dequeueReusableSupplementaryView(ofKind: viewKind.rawValue, withReuseIdentifier: self.defaultSupplementaryViewIdentifier, for: indexPath) as! SpreadsheetCollectionReusableView
            
            supplementaryView.headerDelegate = self
            switch viewKind {
            case .leftRowHeadline:
                 if indexPath.section >= 0 && indexPath.section < self.LastPaymentReceiptArray.count {
                    supplementaryView.infoLabel.text = self.LastPaymentReceiptArray[indexPath.section].partynm
                }
            case .rightRowHeadline:
                supplementaryView.adjustmentButton.tag = indexPath.section
            case .topColumnHeader:
                supplementaryView.infoLabel.text = self.topHeaderLabels[indexPath.item]
       
            case .decorationTopRight:
    //Here I try to mutate the label 
                supplementaryView.infoLabel.text = "View Adjustment"
                
            default:
                break
            }
            
            return supplementaryView
        }
    
    opened by codingdoze 1
  • Color cells from selected cell to headers

    Color cells from selected cell to headers

    Hi everybody,

    I would like that when a cell is selected, the cells between the selected one and the header are colored. To make you understand the idea, I post a Google Flight image that shows the result I would like to achieve. how can I do?

    Screenshot 2022-11-17 alle 10 29 58
    opened by Rufy86 0
  • Request for support for SPM by version number

    Request for support for SPM by version number

    Adding the SwiftSpreadsheet package by branch with SPM works.

    However, if you select a version number, e.g. "Up to Next Minor Version", an error message appears in a dialog. Screen Shot 2021-12-10 at 1 39 08 PM

    I believe the resolution is to publish a release on GitHub.

    opened by iliaskarim 0
  • Carthage support

    Carthage support

    opened by TofPlay 1
Owner
Wojtek Kordylewski
Wojtek Kordylewski
An iOS drop-in UITableView, UICollectionView and UIScrollView superclass category for showing a customizable floating button on top of it.

MEVFloatingButton An iOS drop-in UITableView, UICollectionView, UIScrollView superclass category for showing a customizable floating button on top of

Manuel Escrig 298 Jul 17, 2022
Dwifft is a small Swift library that tells you what the "diff" is between two collections

Dwifft! In 10 seconds Dwifft is a small Swift library that tells you what the "diff" is between two collections, namely, the series of "edit operation

Jack Flintermann 1.8k Dec 12, 2022
A Swift mixin for reusing views easily and in a type-safe way (UITableViewCells, UICollectionViewCells, custom UIViews, ViewControllers, Storyboards…)

Reusable A Swift mixin to use UITableViewCells, UICollectionViewCells and UIViewControllers in a type-safe way, without the need to manipulate their S

Olivier Halligon 2.9k Jan 3, 2023
Netflix and App Store like UITableView with UICollectionView, written in pure Swift 4.2

GLTableCollectionView Branch Status master develop What it is GLTableCollectionView is a ready to use UITableViewController with a UICollectionView fo

Giulio 708 Nov 17, 2022
A generic small reusable components for data source implementation for UITableView/UICollectionView in Swift.

GenericDataSource A generic small reusable components for data source implementation for UITableView/UICollectionView written in Swift. Features Basic

null 132 Sep 8, 2021
Easy and type-safe iOS table and collection views in Swift.

Quick Start TL;DR? SimpleSource is a library that lets you populate and update table views and collection views with ease. It gives you fully typed cl

Squarespace 96 Dec 26, 2022
Spreadsheet CollectionViewLayout in Swift. Fully customizable. 🔶

SwiftSpreadsheet Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Swift 5.0 Inst

Wojtek Kordylewski 637 Dec 30, 2022
Custom CollectionViewLayout class for CollectionView paging mode to work properly

PagingCollectionViewLayout About How to use About ⚠️ Custom class, which is inherited from UICollectionViewFlowLayout, developed for properly work Col

Vladislav 2 Jan 17, 2022
CoreXLSX is a Excel spreadsheet (XLSX) format parser written in pure Swift

CoreXLSX Excel spreadsheet (XLSX) format parser written in pure Swift CoreXLSX is a library focused on representing the low-level structure of the XML

null 684 Dec 21, 2022
Excel spreadsheet (XLSX) format parser written in pure Swift

CoreXLSX Excel spreadsheet (XLSX) format parser written in pure Swift CoreXLSX is a library focused on representing the low-level structure of the XML

null 684 Dec 21, 2022
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

Kishikawa Katsumi 34 Sep 26, 2022
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

Kishikawa Katsumi 34 Sep 26, 2022
SwiftXLSX - A library focused creating Excel spreadsheet (XLSX) files directly on mobile devices

SwiftXLSX Excel spreadsheet (XLSX) format writer on pure SWIFT. SwiftXLSX is a l

null 19 Dec 13, 2022
Reusable GridView with excellent performance and customization that can be time table, spreadsheet, paging and more.

GridView GridView can tile the view while reusing it. It has an API like UIKit that works fast. Even when device rotates it smoothly relayout. Appetiz

Kyohei Ito 830 Dec 23, 2022
Fully customizable and extensible action sheet controller written in Swift

XLActionController By XMARTLABS. XLActionController is an extensible library to quickly create any custom action sheet controller. Examples The action

xmartlabs 3.3k Dec 31, 2022
Former is a fully customizable Swift library for easy creating UITableView based form.

Former is a fully customizable Swift library for easy creating UITableView based form. Submitting Issues Click HERE to get started with filing a bug r

Ryo Aoyama 1.3k Dec 27, 2022
A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.

DTPagerController This is a control for iOS written in Swift. DTPagerController is simple to use and easy to customize. Screenshots Default segmented

Tung Vo 290 Nov 13, 2022
A fully customizable library to easily display Animated Toast Messages in iOS using Swift!

CustomToastView-swift A fully customizable library to easily display Animated Toast Messages in iOS using Swift! Preview - All the custom toasts you c

Leticia Rodriguez 13 Aug 20, 2022
A fully customizable iOS Horizontal PickerView library, written in pure swift

ADDatePicker is Horizontal Date Picker Library written in Swift Requirements Communication Installation Usage Demo Customization Credits License Requi

Abhishek Dave 166 Dec 21, 2022
A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.

DTPagerController This is a control for iOS written in Swift. DTPagerController is simple to use and easy to customize. Screenshots Default segmented

Tung Vo 290 Nov 13, 2022