You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Changelog.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,17 @@
1
1
# Change Log
2
2
3
+
## v2.3.0
4
+
---
5
+
Release Date: **09.02.2018**
6
+
7
+
- Added most important formulas as static method calls in the sub-class Cell.BasicFormulas (round, floor, ceil, min, max, average, median, sum, vlookup)
8
+
- Removed overloaded methods to add cells as type Cell. This can be done now with the overloading of the type object (no code changes necessary)
9
+
- Added new constructors for Address and Range
10
+
- Added demo for the new static formula methods
11
+
- Fixed a bug that kept the stream of the saved file open as long as the program was running
Copy file name to clipboardExpand all lines: Demo/Program.cs
+66-1Lines changed: 66 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,7 @@ static void Main(string[] args)
32
32
Demo6();
33
33
Demo7();
34
34
Demo8();
35
+
Demo9();
35
36
36
37
/* ### PERFORMANCE TESTS ### */
37
38
// # Use tests in this section to test the performance of PicoXLSX
@@ -306,5 +307,69 @@ private static void Demo8()
306
307
workbook.Save();// Save the workbook
307
308
}
308
309
310
+
/// <summary>
311
+
/// This demo shows the usage of basic Excel formulas
312
+
/// </summary>
313
+
privatestaticvoidDemo9()
314
+
{
315
+
Workbookworkbook=newWorkbook("test9.xlsx","sheet1");// Create a new workbook
316
+
List<object>numbers=newList<object>{1.15d,2.225d,13.8d,15d,15.1d,17.22d,22d,107.5d,128d};// Create a list of numbers
317
+
List<object>texts=newList<object>(){"value 1","value 2","value 3","value 4","value 5","value 6","value 7","value 8","value 9"};// Create a list of strings (for vlookup)
318
+
workbook.WS.Value("Numbers",Style.BasicStyles.Bold);// Add a header with a basic style
319
+
workbook.WS.Value("Values",Style.BasicStyles.Bold);// Add a header with a basic style
320
+
workbook.WS.Value("Formula type",Style.BasicStyles.Bold);// Add a header with a basic style
321
+
workbook.WS.Value("Formula value",Style.BasicStyles.Bold);// Add a header with a basic style
322
+
workbook.WS.Value("(See also worksheet2)");// Add a note
323
+
workbook.CurrentWorksheet.AddCellRange(numbers,"A2:A10");// Add the numbers as range
324
+
workbook.CurrentWorksheet.AddCellRange(texts,"B2:B10");// Add the values as range
325
+
326
+
workbook.CurrentWorksheet.SetCurrentCellAddress("D2");// Set the "cursor" to D2
327
+
Cellc;// Create an empty cell object (reusable)
328
+
c=Cell.BasicFormulas.Average(newCell.Range("A2:A10"));// Define an average formula
329
+
workbook.CurrentWorksheet.AddCell("Average","C2");// Add the description of the formula to the worksheet
330
+
workbook.CurrentWorksheet.AddCell(c,"D2");// Add the formula to the worksheet
331
+
332
+
c=Cell.BasicFormulas.Ceil(newCell.Address("A2"),0);// Define a ceil formula
333
+
workbook.CurrentWorksheet.AddCell("Ceil","C3");// Add the description of the formula to the worksheet
334
+
workbook.CurrentWorksheet.AddCell(c,"D3");// Add the formula to the worksheet
335
+
336
+
c=Cell.BasicFormulas.Floor(newCell.Address("A2"),0);// Define a floor formula
337
+
workbook.CurrentWorksheet.AddCell("Floor","C4");// Add the description of the formula to the worksheet
338
+
workbook.CurrentWorksheet.AddCell(c,"D4");// Add the formula to the worksheet
339
+
340
+
c=Cell.BasicFormulas.Round(newCell.Address("A3"),1);// Define a round formula with one digit after the comma
341
+
workbook.CurrentWorksheet.AddCell("Round","C5");// Add the description of the formula to the worksheet
342
+
workbook.CurrentWorksheet.AddCell(c,"D5");// Add the formula to the worksheet
343
+
344
+
c=Cell.BasicFormulas.Max(newCell.Range("A2:A10"));// Define a max formula
345
+
workbook.CurrentWorksheet.AddCell("Max","C6");// Add the description of the formula to the worksheet
346
+
workbook.CurrentWorksheet.AddCell(c,"D6");// Add the formula to the worksheet
347
+
348
+
c=Cell.BasicFormulas.Min(newCell.Range("A2:A10"));// Define a min formula
349
+
workbook.CurrentWorksheet.AddCell("Min","C7");// Add the description of the formula to the worksheet
350
+
workbook.CurrentWorksheet.AddCell(c,"D7");// Add the formula to the worksheet
351
+
352
+
c=Cell.BasicFormulas.Median(newCell.Range("A2:A10"));// Define a median formula
353
+
workbook.CurrentWorksheet.AddCell("Median","C8");// Add the description of the formula to the worksheet
354
+
workbook.CurrentWorksheet.AddCell(c,"D8");// Add the formula to the worksheet
355
+
356
+
c=Cell.BasicFormulas.Sum(newCell.Range("A2:A10"));// Define a sum formula
357
+
workbook.CurrentWorksheet.AddCell("Sum","C9");// Add the description of the formula to the worksheet
358
+
workbook.CurrentWorksheet.AddCell(c,"D9");// Add the formula to the worksheet
359
+
360
+
c=Cell.BasicFormulas.VLookup(13.8d,newCell.Range("A2:B10"),2,true);// Define a vlookup formula (look for the value of the number 13.8)
361
+
workbook.CurrentWorksheet.AddCell("Vlookup","C10");// Add the description of the formula to the worksheet
362
+
workbook.CurrentWorksheet.AddCell(c,"D10");// Add the formula to the worksheet
363
+
364
+
workbook.AddWorksheet("sheet2");// Create a new worksheet
365
+
c=Cell.BasicFormulas.VLookup(workbook.Worksheets[0],newCell.Address("B4"),workbook.Worksheets[0],newCell.Range("B2:C10"),2,true);// Define a vlookup formula in worksheet1 (look for the text right of the (value of) cell B4)
366
+
workbook.WS.Value(c);// Add the formula to the worksheet
367
+
368
+
c=Cell.BasicFormulas.Median(workbook.Worksheets[0],newCell.Range("A2:A10"));// Define a median formula in worksheet1
369
+
workbook.WS.Value(c);// Add the formula to the worksheet
0 commit comments