zero-one-group / fxl

Licence: Apache-2.0 license
fxl is a Clojure spreadsheet library

Programming Languages

clojure
4091 projects
Makefile
30231 projects

Projects that are alternatives of or similar to fxl

fxl.js
ƛ fxl.js is a data-oriented JavaScript spreadsheet library. It provides a way to build spreadsheets using modular, lego-like blocks.
Stars: ✭ 27 (-76.92%)
Mutual labels:  excel, xlsx, spreadsheet, data-oriented
Luckysheet
Luckysheet is an online spreadsheet like excel that is powerful, simple to configure, and completely open source.
Stars: ✭ 9,772 (+8252.14%)
Mutual labels:  excel, xlsx, spreadsheet
Xlnt
📊 Cross-platform user-friendly xlsx library for C++11+
Stars: ✭ 876 (+648.72%)
Mutual labels:  excel, xlsx, spreadsheet
spreadcheetah
SpreadCheetah is a high-performance .NET library for generating spreadsheet (Microsoft Excel XLSX) files.
Stars: ✭ 107 (-8.55%)
Mutual labels:  excel, xlsx, spreadsheet
Readxl
Read excel files (.xls and .xlsx) into R 🖇
Stars: ✭ 585 (+400%)
Mutual labels:  excel, xlsx, spreadsheet
Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+24241.03%)
Mutual labels:  excel, xlsx, spreadsheet
Documentbuilder
ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
Stars: ✭ 61 (-47.86%)
Mutual labels:  excel, xlsx, spreadsheet
Unioffice
Pure go library for creating and processing Office Word (.docx), Excel (.xlsx) and Powerpoint (.pptx) documents
Stars: ✭ 3,111 (+2558.97%)
Mutual labels:  excel, xlsx, spreadsheet
Phpspreadsheet
A pure PHP library for reading and writing spreadsheet files
Stars: ✭ 10,627 (+8982.91%)
Mutual labels:  excel, xlsx, spreadsheet
Xlsx
Fast and reliable way to work with Microsoft Excel™ [xlsx] files in Golang
Stars: ✭ 132 (+12.82%)
Mutual labels:  excel, xlsx, spreadsheet
Test files
📚 SheetJS Test Files (XLS/XLSX/XLSB and other spreadsheet formats)
Stars: ✭ 150 (+28.21%)
Mutual labels:  excel, xlsx, spreadsheet
Reogrid
Fast and powerful .NET spreadsheet component, support data format, freeze, outline, formula calculation, chart, script execution and etc. Compatible with Excel 2007 (.xlsx) format and working on .NET 3.5 (or client profile), WPF and Android platform.
Stars: ✭ 532 (+354.7%)
Mutual labels:  excel, xlsx, spreadsheet
Docjure
Read and write Office documents from Clojure
Stars: ✭ 510 (+335.9%)
Mutual labels:  excel, xlsx, spreadsheet
xltpl
A python module to generate xls/x files from a xls/x template.
Stars: ✭ 46 (-60.68%)
Mutual labels:  excel, xlsx, spreadsheet
J
❌ Multi-format spreadsheet CLI (now merged in http://github.com/sheetjs/js-xlsx )
Stars: ✭ 343 (+193.16%)
Mutual labels:  excel, xlsx, spreadsheet
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+761.54%)
Mutual labels:  excel, xlsx, spreadsheet
xlsx-reader
xlsx-reader is a PHP library for fast and efficient reading of XLSX spreadsheet files. Its focus is on reading the data contained within XLSX files, disregarding all document styling beyond that which is strictly necessary for data type recognition. It is built to be usable for very big XLSX files in the magnitude of multiple GBs.
Stars: ✭ 40 (-65.81%)
Mutual labels:  excel, xlsx, spreadsheet
excel validator
Python script to validate data in Excel files
Stars: ✭ 14 (-88.03%)
Mutual labels:  excel, xlsx, spreadsheet
ExcelFormulaBeautifier
Excel Formula Beautifer,make Excel formulas more easy to read,Excel公式格式化/美化,将Excel公式转为易读的排版
Stars: ✭ 27 (-76.92%)
Mutual labels:  excel, xlsx, spreadsheet
Excelize
Golang library for reading and writing Microsoft Excel™ (XLSX) files.
Stars: ✭ 10,286 (+8691.45%)
Mutual labels:  excel, xlsx, spreadsheet

fxl (/ˈfɪk.səl/ or "pixel" with an f) is a Clojure library for manipulating spreadsheets.

Continuous Integration Code Coverage Clojars Project

WARNING! This library is still unstable. Some information here may be outdated. Do not use it in production just yet!

See docjure and excel-clj for more mature alternatives.

Introduction

The goal of the project is to provide a composable data-oriented spreadsheet interface for Clojure. The library is written with simplicity in mind - particularly as discussed in Rich Hickey's talk Simplicity Matters on the list-and-order problem.

If order matters, complexity has been introduced to the system

Rich Hickey, Simplicity Matters

What fxl attempts to do differently to docjure and excel-clj is to represent spreadsheets as an unordered collection of maps, instead of relying on tabular formats. This makes it easier to deal with independent, smaller components of the spreadsheet and simply apply concat to put together different components of a spreadsheet.

cljdoc slack zulip

Examples

Map Representation of Cells

A fxl cell is represented by a map that tells us its value, location and style. For instance:

{:value -2.2
 :coord {:row 4 :col 3 :sheet "Growth"}
 :style {:data-format "0.00%" :background-colour :yellow}}

is rendered as a highlighted cell with a value of "-2.2%" on the fifth row and fourth column of a sheet called "Growth".

By knowing cells, you know almost all of fxl! The rest of the library is composed of IO functions such as read-xlsx! and write-xlsx! and helper functions to transform Clojure data structures into cell maps.

To find out more about the available styles, see their specs.

Creating Simple Spreadsheets with Builtin Clojure

Suppose we would like to create a spreadsheet such as the following:

| Item     | Cost     |
| -------- | -------- |
| Rent     | 1000     |
| Gas      | 100      |
| Food     | 300      |
| Gym      | 50       |
|          |          |
| Total    | 1450     |

Assume that we have the cost data in the following form:

(def costs
  [{:item "Rent" :cost 1000}
   {:item "Gas"  :cost 100}
   {:item "Food" :cost 300}
   {:item "Gym"  :cost 50}])

We would break the spreadsheet down into three components, namely the header, the body and the total:

(require '[zero-one.fxl.core :as fxl])

(def header-cells
  [{:value "Item" :coord {:row 0 :col 0} :style {}}
   {:value "Cost" :coord {:row 0 :col 1} :style {}}])

(def body-cells
  (flatten
    (for [[row cost] (map vector (range) costs)]
      (list
        {:value (:item cost) :coord {:row (inc row) :col 0} :style {}}
        {:value (:cost cost) :coord {:row (inc row) :col 1} :style {}}))))

(def total-cells
  (let [row        (count costs)
        total-cost (apply + (map :cost costs))]
    [{:value "Total"    :coord {:row (+ row 2) :col 0} :style {}}
     {:value total-cost :coord {:row (+ row 2) :col 1} :style {}}]))

(fxl/write-xlsx!
  (concat header-cells body-cells total-cells)
  "examples/spreadsheets/write_to_plain_excel.xlsx")

In fact, style is optional, so we can actually remove :style {} from all the maps.

While both these methods work, dealing with the coordinates can be fiddly. We can make the intent clearer using fxl helper functions.

Creating Simple Spreadsheets with Helper Functions

Here we use row->cells, table->cells, pad-below and concat-below to help us initialise and navigate relative coordinates.

(def header-cells (fxl/row->cells ["Item" "Cost"]))

(def body-cells
  (fxl/records->cells [:item :cost] costs))

(def total-cells
  (let [total-cost (apply + (map :cost costs))]
    (fxl/row->cells ["Total" total-cost])))

(fxl/write-xlsx!
  (fxl/concat-below header-cells
                    (fxl/pad-below body-cells)
                    total-cells)
  "examples/spreadsheets/write_to_plain_excel_with_helpers.xlsx")

More helper functions are available - see here.

Modular Styling

With a Clojure-map representation for cells, manipulating the spreadsheet is easy using built-in functions. Suppose we would like to:

  1. highlight the header row and make it bold
  2. make the total row bold
  3. horizontally align all cells to the center

We can achieve this by composing simple styling functions:

(defn bold [cell]
  (assoc-in cell [:style :bold] true))

(defn highlight [cell]
  (assoc-in cell [:style :background-colour] :grey_25_percent))

(defn align-center [cell]
  (assoc-in cell [:style :horizontal] :center))

(def all-cells
  (map align-center
    (fxl/concat-below
      (map (comp bold highlight) header-cells)
      (fxl/pad-below body-cells)
      (map bold total-cells))))

Installation

Add the following to your project.clj dependency:

Clojars Project

Future Work

Features:

  • Core:
    • Column width and row heights.
    • Freezing panes.
    • Excel coords -> index coords.
    • Support merged cells.
    • Support data-val cells.
  • Support to Google Sheet API.
  • Error handling with failjure.
  • Property-based testing.

License

Copyright 2020 Zero One Group.

fxl is licensed under Apache License v2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].