Skip to content

Commit

Permalink
refactor to use cells with formats
Browse files Browse the repository at this point in the history
  • Loading branch information
sjhorn committed Apr 13, 2024
1 parent f0ae8b8 commit dcfe3bc
Show file tree
Hide file tree
Showing 39 changed files with 1,698 additions and 1,078 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![GitHub Stars](https://img.shields.io/github/stars/sjhorn/visicalc_engine.svg)](https://github.com/sjhorn/visicalc_engine/stargazers)
![GitHub License](https://img.shields.io/github/license/sjhorn/visicalc_engine)

This package implements a clone of the VisiCalc spreadsheet engine in a dart library that works by parsing the stringw of cells and calculating the result considering references to other cells.
This package implements a clone of the VisiCalc spreadsheet engine in a dart library that works by parsing the strings of cells (Map<A1,String>) and calculating the result considering references to other cells.

The screenshot below shows the original user interface of Visicalc made by [Dan Bricklin and Bob Frankston](http://danbricklin.com/visicalc.htm).
![VisiCalc Logo from Wikipedia](https://upload.wikimedia.org/wikipedia/commons/thumb/8/8f/Visicalc_logo.svg/320px-Visicalc_logo.svg.png)
Expand Down
20 changes: 11 additions & 9 deletions example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,31 @@ import 'package:visicalc_engine/visicalc_engine.dart';

void main(List<String> arguments) {
final sheet = {
'A1'.a1: '-12.2',
'A1'.a1: '/FR-12.2',
'A2'.a1: '(a5+45)',
'A3'.a1: '13',
'A3'.a1: '/F*13',
'A4'.a1: '+A2+A5-A6',
'A5'.a1: '-A3/2+2',
'A6'.a1: '.23*2',
'A6'.a1: '/F\$.23*2',
'B1'.a1: 'A1+A3*3',
'B2'.a1: '(A1+A3)*3',
'B3'.a1: '12.23e-12',
'B4'.a1: '.23e12',
'B5'.a1: 'b4',
'B5'.a1: '/FRb4',
'B6'.a1: 'b2',
'B7'.a1: '@sum(a1...b6)',
'D13'.a1: 'b2',
};
final worksheet = VisicalcEngine(sheet, parseErrorThrows: true);
for (final a1 in worksheet) {
print('$a1: ${worksheet[a1]}');
}
final worksheet = Engine(sheet, parseErrorThrows: true);
print(worksheet);

// Change cell
var b5 = worksheet["B5".a1];
print('B5 formula was ${b5?.formulaType?.asFormula} = $b5');
print('Seeting to a1');
print('Now setting B5 to formula a1');
worksheet['B5'.a1] = 'a1';

b5 = worksheet["B5".a1];
print('Now B5 formula is ${b5?.formulaType?.asFormula} = $b5');
print(worksheet);
}
Loading

0 comments on commit dcfe3bc

Please sign in to comment.