DanieleGregori/ SpreadsheetToolkit

Tools for complex spreadsheet analysis

Contributed by: Daniele Gregori

Installation Instructions

To install this paclet in your Wolfram Language environment, evaluate this code:
PacletInstall["DanieleGregori/SpreadsheetToolkit"]


To load the code after installation, evaluate this code:
Needs["DanieleGregori`SpreadsheetToolkit`"]

Paclet Guide

Examples

Basic Examples (4) 

Convert a cell into a grid position and vice-versa:

In[1]:=
SpreadsheetConvert["J2"]
Out[1]=
In[2]:=
SpreadsheetConvert[{2, 10}]
Out[2]=

Import a spreadsheet sheets, data, formulas and defined names:

In[3]:=
file1 = URLDownload[
   "https://www.wolframcloud.com/obj/064eb405-e9b5-4e95-941a-7898dd493f80",
   FileNameJoin[{$TemporaryDirectory, "example_01.xlsx"}]];
In[4]:=
{sheets, data, formulas, names} = ImportSpreadsheet[file1]
Out[4]=

Parse all the cells in the formulas:

In[5]:=
AssociationMap[
  SpreadsheetParse,
  Flatten[formulas /. "" -> Nothing]] // Column@*Normal
Out[5]=

Trace the dependencies of a cell:

In[6]:=
trace = SpreadsheetTrace[file1, "D1"]
Out[6]=
In[7]:=
ExpressionTree[trace, "Atoms"]
Out[7]=

Scope (6) 

A very complex trace as a ConditionalExpression in terms of sub-traces:

In[8]:=
file11 = URLDownload[
   "https://www.wolframcloud.com/obj/2b7da83d-0149-4c42-971f-93961c7e7f90",
   FileNameJoin[{$TemporaryDirectory, "example_11.xlsx"}]];
In[9]:=
largecondtrace = SpreadsheetTrace[file11, "6 - Ratios!C73", "TraceDuplicates" -> False];
In[10]:=
Short[largecondtrace, 15]
Out[10]=
In[11]:=
LeafCount[largecondtrace]
Out[11]=

All the final elementary cells, with a numeric value:

In[12]:=
finalcells = Cases[largecondtrace, {s_String, _?NumericQ} :> s, Infinity] // DeleteDuplicates;
In[13]:=
Length[finalcells]
Out[13]=

These are still a lot, so contract spreadsheet cells by rows:

In[14]:=
finalcellscontracted = ContractSpreadsheetRows[finalcells];
In[15]:=
Short[finalcellscontracted, 5]
Out[15]=
In[16]:=
Length[finalcellscontracted]
Out[16]=

Contract again by columns:

In[17]:=
finalcellscontracted = Flatten@MapAt[
    ContractSpreadsheetColumns,
    finalcellscontracted // ResourceFunction["SelectDiscard"][StringContainsQ[#, ":"] &],
    2];
In[18]:=
Length[finalcellscontracted]
Out[18]=

Finally contract row ranges:

In[19]:=
finalcellscontracted =
 ContractSpreadsheetRowRanges@finalcellscontracted
Out[19]=
In[20]:=
Length[finalcellscontracted]
Out[20]=

Check these ranges expand back into the original final cells:

In[21]:=
Union@Flatten[
   SpreadsheetExpand /@ finalcellscontracted] == Union@finalcells
Out[21]=

Publisher

Daniele Gregori

Compatibility

Wolfram Language Version 13

Version History

  • 1.0.0 – 23 November 2026

License Information

MIT License

Paclet Source

See Also