Code Monkey home page Code Monkey logo

libxlsxwriterswiftsample's Introduction

LibXlsxWriterSwiftSample

This repository contains a Xcode example project showing how to use the libxlsxwriter CocoaPod with Swift for iOS.

Goal of this Repository

While using most of the C API from Swift is pretty straight forward, in some cases there are some modifications needed, in order to get everything working together. This repository aims to provide some examples on how to deal with such cases in Swift 5. These examples are based on the examples provided for the original C library, that can be found here.

Screencast

Screencast

Basic Setup

If you want to use this Pod in your own project, all you have to do is to add this

pod 'libxlsxwriter', '~> 0.9'

line to your Podfile and run pod install. In your Swift source file you can now import

import xlsxwriter

and use it's various c functions.

Basic Example

A basic example on how to generate a .xlsx file and save it to the app's documents directory would look like that:

import Foundation
import xlsxwriter

class Hello{
    func generate() -> URL {
        let documentDirectory = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor:nil, create:false)
        let fileURL = documentDirectory.appendingPathComponent("hello_world.xlsx")
        
        let workbook = workbook_new((fileURL.absoluteString.dropFirst(6) as NSString).fileSystemRepresentation)
        let worksheet = workbook_add_worksheet(workbook, nil)
        worksheet_write_string(worksheet, 0, 0, "Hello", nil)
        worksheet_write_number(worksheet, 1, 0, 123, nil)
        workbook_close(workbook)
        
        return fileURL
    }
}

Only run sample app

You can test the sample app right in your browser here but the emulator does not support previewing the generated excel files.

I will soon add a .ipa file, that can be installed on your physical device, using for example AltStore.

libxlsxwriterswiftsample's People

Contributors

frankenapps avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.