Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/Build.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageReference Include="Fake.DotNet.MSBuild" Version="6.1.3" />
<PackageReference Include="Fake.IO.FileSystem" Version="6.1.3" />
<PackageReference Include="Fake.Tools.Git" Version="6.1.3" />
<PackageReference Include="Fake.Extensions.Release" Version="0.3.0" />
<PackageReference Include="Fake.Extensions.Release" Version="1.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "8.0.1",
"rollForward": "latestMinor"
}
}
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"mocha": "^10.2.0"
},
"dependencies": {
"@nfdi4plants/exceljs": "^0.3.0"
"@nfdi4plants/exceljs": "^0.4.0"
}
}
4 changes: 2 additions & 2 deletions playground.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ ws.CellCollection.RemoveCellAt(1, 1)

//let cellSeq = List.init 2 (fun i -> FsCell.create (i + 1) 1 "v")
//let testFCC = FsCellsCollection()
//testFCC.Add cellSeq
//testFCC.AddMany cellseq
//testFCC.GetCells()
//let testCells = testFCC.GetCells() |> Seq.map (fun c -> c.Copy())
//let testFCC2 = FsCellsCollection()
Expand Down Expand Up @@ -224,7 +224,7 @@ ws.CellCollection.RemoveCellAt(1, 1)
//let copy (this : FsCellsCollection) =
// let newCellsColl = FsCellsCollection()
// let cells : seq<FsCell> = this.GetCells()
// newCellsColl.Add cells
// newCellsColl.AddMany cells

//let testCell = FsCell.create 1 1 "Hallo"
//let dummyFsCellsCollection4 = FsCellsCollection().Add testCell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" />
<Compile Include="FsSparseMatrix.fs" />
<Compile Include="Formatters.fs" />
<Compile Include="Extension.fs" />
Expand Down
7 changes: 7 additions & 0 deletions src/FsSpreadsheet.Interactive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# FsSpreadsheet.Interactive

This project provides interactive features for working with spreadsheets in Polyglot Notebooks, by visualizing Sheets as Tables.

For usage, just reference the `#r "nuget: FsSpreadsheet.Interactive"` package in your Polyglot Notebook.

<img width="2041" height="1144" alt="image" src="https://github.com/user-attachments/assets/0073e48b-c910-4e4d-bf1b-9b5c0bbff698" />
10 changes: 5 additions & 5 deletions src/FsSpreadsheet.Js/Cell.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module JsCell =
/// <param name="jsCell"></param>
let readToFsCell worksheetName rowIndex columnIndex (jsCell: Cell) =
let t = enum<Unions.ValueType>(jsCell.``type``)
let fsadress = FsAddress(jsCell.address)
let fsadress = FsAddress.fromString(jsCell.address)
let createFscell = fun dt v -> FsCell(v,dt,address = fsadress)
let vTemp = string jsCell.value.Value
let fscell =
Expand Down Expand Up @@ -73,15 +73,15 @@ module JsCell =
let b = false
createFscell DataType.Boolean b
| anyElse ->
let msg = sprintf "ValueType 'Format' (%s) is not fully implemented in FsSpreadsheet and is handled as string input. In %s: (%i,%i)" anyElse worksheetName rowIndex columnIndex
log msg
//let msg = sprintf "ValueType 'Format' (%s) is not fully implemented in FsSpreadsheet and is handled as string input. In %s: (%i,%i)" anyElse worksheetName rowIndex columnIndex
//log msg
anyElse |> createFscell DataType.String
| ValueType.Hyperlink ->
//log (c.value.Value?text)
jsCell.value.Value?hyperlink |> createFscell DataType.String
| anyElse ->
let msg = sprintf "ValueType `%A` (%s) is not fully implemented in FsSpreadsheet and is handled as string input. In %s: (%i,%i)" anyElse vTemp worksheetName rowIndex columnIndex
log msg
//let msg = sprintf "ValueType `%A` (%s) is not fully implemented in FsSpreadsheet and is handled as string input. In %s: (%i,%i)" anyElse vTemp worksheetName rowIndex columnIndex
//log msg
vTemp |> createFscell DataType.String
fscell

Expand Down
3 changes: 3 additions & 0 deletions src/FsSpreadsheet.Js/Contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Increase nfdi4plants/exceljs dependency

- Make sure that the version specified by the Femto syntax in FsSpreadhsheet.Js.fsproj fits the new version.
3 changes: 2 additions & 1 deletion src/FsSpreadsheet.Js/FsSpreadsheet.Js.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</PropertyGroup>

<ItemGroup>
<None Include="CONTRIBUTING.md" />
<None Include="..\..\docs\img\logo.png" Link="logo.png">
<PackagePath>\</PackagePath>
<Pack>true</Pack>
Expand All @@ -33,7 +34,7 @@
<ItemGroup>
<PackageReference Include="Fable.Exceljs" Version="1.6.0" />
<PackageReference Include="Fable.Promise" Version="3.2.0" />
<PackageReference Include="Thoth.Json.JavaScript" Version="0.1.0" />
<PackageReference Include="Thoth.Json.JavaScript" Version="0.4.1" />
</ItemGroup>

<!-- Add source files to "fable" folder in Nuget package -->
Expand Down
2 changes: 1 addition & 1 deletion src/FsSpreadsheet.Js/Table.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module JsTable =

let readToFsTable(table:ITableRef) =
let table = table.table.Value
let tableRef = table.tableRef |> FsRangeAddress
let tableRef = table.tableRef |> FsRangeAddress.fromString
let tableName = if isNull table.displayName then table.name else table.displayName
let table = FsTable(tableName, tableRef, table.totalsRow, table.headerRow)
table
2 changes: 1 addition & 1 deletion src/FsSpreadsheet.Net/FsExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ module FsExtensions =
/// </summary>
static member fromXlsxTable table =
let topLeftBoundary, bottomRightBoundary = Table.getArea table |> Table.Area.toBoundaries
let ra = FsRangeAddress(FsAddress(topLeftBoundary), FsAddress(bottomRightBoundary))
let ra = FsRangeAddress(FsAddress.fromString(topLeftBoundary), FsAddress.fromString(bottomRightBoundary))
let totalsRowShown = if table.TotalsRowShown = null then false else table.TotalsRowShown.Value
FsTable(table.DisplayName, ra, totalsRowShown, true)

Expand Down
2 changes: 1 addition & 1 deletion src/FsSpreadsheet.Net/FsSpreadsheet.Net.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.16.0" />
<PackageReference Include="Thoth.Json.Newtonsoft" Version="0.1.0" />
<PackageReference Include="Thoth.Json.Newtonsoft" Version="0.3.2" />
<None Include="..\..\docs\img\logo.png" Pack="true" PackagePath="\" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/FsSpreadsheet.Net/ZipArchiveReader.fs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ let parseTable (sheet : ZipArchiveEntry) =
while reader.Read() do
if XmlReader.isElemWithName reader "table" then
let area = reader.GetAttribute("ref")
let ra = FsRangeAddress(area)
let ra = FsRangeAddress.fromString(area)
let totalsRowShown =
let attribute = reader.GetAttribute("totalsRowShown")
match attribute with
Expand Down Expand Up @@ -283,7 +283,7 @@ let parseWorksheet (name : string) (styles : Styles) (sharedStrings : SharedStri
f <- cellReader.ReadElementContentAsString()
if v <> null && v <> "" || f <> null then
let cellValue,dataType = parseCell sharedStrings styles v t s f
let cell = FsCell(cellValue,dataType = dataType,address = FsAddress(r))
let cell = FsCell(cellValue,dataType = dataType,address = FsAddress.fromString(r))
ws.AddCell(cell) |> ignore
if XmlReader.isElemWithName reader "tablePart" then
let id = reader.GetAttribute("r:id")
Expand Down
2 changes: 1 addition & 1 deletion src/FsSpreadsheet.Py/FsSpreadsheet.Py.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="Fable.Openpyxl" Version="0.2.0" />
<PackageReference Include="Thoth.Json.Python" Version="0.1.0" />
<PackageReference Include="Thoth.Json.Python" Version="0.5.1" />
</ItemGroup>

<!-- Add source files to "fable" folder in Nuget package -->
Expand Down
2 changes: 1 addition & 1 deletion src/FsSpreadsheet.Py/Table.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ module PyTable =
let toFsTable(table:Table) =
let name = if isNull table.displayName then table.name else table.displayName
let ref = table.ref
FsTable(name,FsRangeAddress(ref))
FsTable(name,FsRangeAddress.fromString(ref))
2 changes: 1 addition & 1 deletion src/FsSpreadsheet/Cells/FsCell.fs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type FsCell (value : obj, ?dataType : DataType, ?address : FsAddress) =
let mutable _rowIndex : int = address |> Option.map (fun a -> a.RowNumber) |> Option.defaultValue 0
let mutable _columnIndex : int = address |> Option.map (fun a -> a.ColumnNumber) |> Option.defaultValue 0

new(value: IConvertible, ?dataType : DataType, ?address : FsAddress) = FsCell(box value, ?dataType = dataType, ?address = address)
//new(value: IConvertible, ?dataType : DataType, ?address : FsAddress) = FsCell(box value, ?dataType = dataType, ?address = address)
/// Creates an empty FsCell, set at row 0, column 0 (1-based).
static member inline empty () = FsCell ("", DataType.Empty, FsAddress(0,0))

Expand Down
51 changes: 24 additions & 27 deletions src/FsSpreadsheet/Cells/FsCellsCollection.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace FsSpreadsheet

open System.Collections.Generic
open Fable.Core

module Dictionary =

Expand All @@ -13,6 +14,7 @@ module Dictionary =
/// <summary>
///
/// </summary>
[<AttachMembers>]
type FsCellsCollection() =

// ---------
Expand Down Expand Up @@ -98,7 +100,7 @@ type FsCellsCollection() =
/// <remarks>Derives row- and columnIndices from the FsAddress of the FsCells.</remarks>
static member createFromCells (cells : seq<FsCell>) =
let fcc = FsCellsCollection()
fcc.Add cells
fcc.AddMany cells
fcc

// TO DO: Must create deep copy methods for ALL other objects in it first, and call them here.
Expand All @@ -107,7 +109,7 @@ type FsCellsCollection() =
// let newCellsColl = FsCellsCollection()
// let oldCells : seq<FsCell> = this.GetCells()
// let newCells = // create deep copy here
// newCellsColl.Add cells
// newCellsColl.AddMany cells

///// <summary>
///// Creates and returns a deep copy of an FsCellsCollection.
Expand Down Expand Up @@ -138,10 +140,12 @@ type FsCellsCollection() =
/// <summary>
/// Adds an FsCell of given rowIndex and columnIndex to the FsCellsCollection.
/// </summary>
member this.Add(row : int32, column : int32, cell : FsCell) =
member this.Add(cell : FsCell, ?row : int32, ?column : int32) =

cell.RowNumber <- row
cell.ColumnNumber <- column
if row.IsSome then cell.RowNumber <- row.Value
if column.IsSome then cell.ColumnNumber <- column.Value
let row = cell.RowNumber
let column = cell.ColumnNumber
_count <- _count + 1

FsCellsCollection.IncrementUsage(_rowsUsed, row);
Expand Down Expand Up @@ -170,14 +174,7 @@ type FsCellsCollection() =
/// Adds an FsCell of given rowIndex and columnIndex to an FsCellsCollection.
/// </summary>
static member addCellWithIndeces rowIndex colIndex (cell : FsCell) (cellsCollection : FsCellsCollection) =
cellsCollection.Add(rowIndex, colIndex, cell)

/// <summary>
/// Adds an FsCell to the FsCellsCollection.
/// </summary>
/// <remarks>Derives row- and columnIndex from the FsAddress of the FsCell.</remarks>
member this.Add(cell : FsCell) =
this.Add(cell.Address.RowNumber, cell.Address.ColumnNumber, cell)
cellsCollection.Add(cell, rowIndex, colIndex)

/// <summary>
/// Adds an FsCell to an FsCellsCollection.
Expand All @@ -191,15 +188,15 @@ type FsCellsCollection() =
/// Adds FsCells to the FsCellsCollection.
/// </summary>
/// <remarks>Derives row- and columnIndeces from the FsAddress of the FsCells.</remarks>
member this.Add(cells : seq<FsCell>) =
member this.AddMany(cells : seq<FsCell>) =
cells |> Seq.iter (this.Add >> ignore)

/// <summary>
/// Adds FsCells to an FsCellsCollection.
/// </summary>
/// <remarks>Derives row- and columnIndeces from the FsAddress of the FsCells.</remarks>
static member addCells (cells : seq<FsCell>) (cellsCollection : FsCellsCollection) =
cellsCollection.Add cells
cellsCollection.AddMany cells
cellsCollection

/// <summary>
Expand Down Expand Up @@ -326,7 +323,7 @@ type FsCellsCollection() =
/// <summary>
/// Returns the FsCells from given rowStart to rowEnd and columnStart to columnEnd and fulfilling the predicate.
/// </summary>
member this.GetCells(rowStart : int32, columnStart : int32, rowEnd : int32, columnEnd : int32, predicate : FsCell -> bool) =
member this.GetCellsInRangeBy(rowStart : int32, columnStart : int32, rowEnd : int32, columnEnd : int32, predicate : FsCell -> bool) =

let finalRow = if rowEnd > _maxRowUsed then _maxRowUsed else rowEnd
let finalColumn = if columnEnd > _maxColumnUsed then _maxColumnUsed else columnEnd
Expand All @@ -347,25 +344,25 @@ type FsCellsCollection() =
/// Returns the FsCells from an FsCellsCollection with given rowStart to rowEnd and columnStart to columnEnd and fulfilling the predicate.
/// </summary>
static member filterCellsFromTo rowStart columnStart rowEnd columnEnd (predicate : FsCell -> bool) (cellsCollection : FsCellsCollection) =
cellsCollection.GetCells(rowStart, columnStart, rowEnd, columnEnd, predicate)
cellsCollection.GetCellsInRangeBy(rowStart, columnStart, rowEnd, columnEnd, predicate)

/// <summary>
/// Returns the FsCells from given startAddress to lastAddress and fulfilling the predicate.
/// </summary>
member this.GetCells(startAddress : FsAddress, lastAddress : FsAddress, predicate : FsCell -> bool) =
this.GetCells(startAddress.RowNumber,startAddress.ColumnNumber,lastAddress.RowNumber,lastAddress.ColumnNumber, predicate)
member this.GetCellsInStringRangeBy(startAddress : FsAddress, lastAddress : FsAddress, predicate : FsCell -> bool) =
this.GetCellsInRangeBy(startAddress.RowNumber,startAddress.ColumnNumber,lastAddress.RowNumber,lastAddress.ColumnNumber, predicate)


/// <summary>
/// Returns the FsCells from an FsCellsCollection with given startAddress to lastAddress and fulfilling the predicate.
/// </summary>
static member filterCellsFromToAddress startAddress lastAddress (predicate : FsCell -> bool) (cellsCollection : FsCellsCollection) =
cellsCollection.GetCells(startAddress, lastAddress, predicate)
cellsCollection.GetCellsInStringRangeBy(startAddress, lastAddress, predicate)

/// <summary>
/// Returns the FsCells from given rowStart to rowEnd and columnStart to columnEnd.
/// </summary>
member this.GetCells(rowStart : int32, columnStart : int32, rowEnd : int32, columnEnd : int32) =
member this.GetCellsInRange(rowStart : int32, columnStart : int32, rowEnd : int32, columnEnd : int32) =
let finalRow = if rowEnd > _maxRowUsed then _maxRowUsed else rowEnd
let finalColumn = if columnEnd > _maxColumnUsed then _maxColumnUsed else columnEnd
seq {
Expand All @@ -385,19 +382,19 @@ type FsCellsCollection() =
/// Returns the FsCells from an FsCellsCollection with given rowStart to rowEnd and columnStart to columnEnd.
/// </summary>
static member getCellsFromTo rowStart columnStart rowEnd columnEnd (cellsCollection : FsCellsCollection) =
cellsCollection.GetCells(rowStart, columnStart, rowEnd, columnEnd)
cellsCollection.GetCellsInRange(rowStart, columnStart, rowEnd, columnEnd)

/// <summary>
/// Returns the FsCells from given startAddress to lastAddress.
/// </summary>
member this.GetCells(startAddress : FsAddress, lastAddress : FsAddress) =
this.GetCells(startAddress.RowNumber,startAddress.ColumnNumber,lastAddress.RowNumber,lastAddress.ColumnNumber)
member this.GetCellsInStringRange(startAddress : FsAddress, lastAddress : FsAddress) =
this.GetCellsInRange(startAddress.RowNumber,startAddress.ColumnNumber,lastAddress.RowNumber,lastAddress.ColumnNumber)

/// <summary>
/// Returns the FsCells from an FsCellsCollection with given startAddress to lastAddress.
/// </summary>
static member getCellsFromToAddress startAddress lastAddress (cellsCollection : FsCellsCollection) =
cellsCollection.GetCells(startAddress, lastAddress)
cellsCollection.GetCellsInStringRange(startAddress, lastAddress)

//public int FirstRowUsed(int rowStart, int columnStart, int rowEnd, int columnEnd, XLCellsUsedOptions options,
// Func<IXLCell, Boolean> predicate = null)
Expand Down Expand Up @@ -670,7 +667,7 @@ type FsCellsCollection() =
/// Returns all FsCells in the given columnIndex.
/// </summary>
member this.GetCellsInColumn(colIndex) =
this.GetCells(1, colIndex, _maxRowUsed, colIndex)
this.GetCellsInRange(1, colIndex, _maxRowUsed, colIndex)

/// <summary>
/// Returns all FsCells in an FsCellsCollection with the given columnIndex.
Expand All @@ -682,7 +679,7 @@ type FsCellsCollection() =
/// Returns all FsCells in the given rowIndex.
/// </summary>
member this.GetCellsInRow(rowIndex) =
this.GetCells(rowIndex, 1, rowIndex, _maxColumnUsed)
this.GetCellsInRange(rowIndex, 1, rowIndex, _maxColumnUsed)

/// <summary>
/// Returns all FsCells in an FsCellsCollection with the given rowIndex.
Expand Down
Loading
Loading