FsSpreadsheet Documentation

FsSpreadsheet is a library for reading and writing spreadsheets in F#, Javascript and Python using Fable. It is a wrapper of the Python library openpyxl (https://openpyxl.readthedocs.io/en/stable/) and the Javascript library exceljs (https://www.npmjs.com/package/@nfdi4plants/exceljs).

Installation

F#

Project

dotnet add package FsSpreadsheet.Net

Script

#r "nuget: FsSpreadsheet.Net"

open FsSpreadsheet
open FsSpreadsheet.Net

Javascript

npm install @fslab/fsspreadsheet

Python

pip install fsspreadsheet

Usage_Xlsx_IO

F#

open FsSpreadsheet
open FsSpreadsheet.Net

let path = "path/to/spreadsheet.xlsx"

let wb = FsWorkbook.fromXlsxFile(path)

let newPath = "path/to/new/spreadsheet.xlsx"

wb.ToXlsxFile(newPath)

Javascript

import { Xlsx } from '@fslab/fsspreadsheet/Xlsx.js';

const path = "path/to/spreadsheet.xlsx"

const wb = Xlsx.fromXlsxFile(path)

const newPath = "path/to/new/spreadsheet.xlsx"

Xlsx.toXlsxFile(newPath,wb)

Python

from fsspreadsheet.xlsx import Xlsx

path = "path/to/spreadsheet.xlsx"

wb = Xlsx.from_xlsx_file(path)

newPath = "path/to/new/spreadsheet.xlsx"

Xlsx.to_xlsx_file(newPath,wb)

Usage_Json_IO

F#

open FsSpreadsheet
open FsSpreadsheet.Net

let path = "path/to/spreadsheet.json"

let wb = FsWorkbook.fromJsonFile(path)

let newPath = "path/to/new/spreadsheet.json"

wb.ToJsonFile(newPath)

Javascript

import { Json } from '@fslab/fsspreadsheet/Json.js';

const path = "path/to/spreadsheet.json"

const wb = Json.fromJsonFile(path)

const newPath = "path/to/new/spreadsheet.json"

Json.toJsonFile(newPath,wb)

Python

from fsspreadsheet.json import Json

path = "path/to/spreadsheet.json"

wb = Json.from_json_file(path)

newPath = "path/to/new/spreadsheet.json"

Json.to_json_file(newPath,wb)
namespace FsSpreadsheet
namespace FsSpreadsheet.Net
val path: string
val wb: FsWorkbook
Multiple items
type FsWorkbook = interface IDisposable new: unit -> FsWorkbook member AddWorksheet: sheet: FsWorksheet -> unit member AddWorksheets: sheets: seq<FsWorksheet> -> unit member Copy: unit -> FsWorkbook member GetTables: unit -> FsTable[] member GetWorksheetAt: index: int -> FsWorksheet member GetWorksheetByName: sheetName: string -> FsWorksheet member GetWorksheets: unit -> ResizeArray<FsWorksheet> member InitWorksheet: name: string -> FsWorksheet ...
<summary> Creates an empty FsWorkbook. </summary>

--------------------
new: unit -> FsWorkbook
static member FsWorkbook.fromXlsxFile: filePath: string -> FsWorkbook
val newPath: string
member FsWorkbook.ToXlsxFile: path: string -> unit
static member FsWorkbook.fromJsonFile: filePath: string -> FsWorkbook
member FsWorkbook.ToJsonFile: path: string * ?spaces: int -> unit