Skip to content

Commit 3f7de93

Browse files
Update v2.3.0
1 parent 50b2f11 commit 3f7de93

File tree

558 files changed

+4277
-3123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

558 files changed

+4277
-3123
lines changed

Changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Change Log
22

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
12+
- Minor bug fixes
13+
- Documentation update
14+
315
## v2.2.0
416
---
517
Release Date: **10.12.2017**

Demo/Program.cs

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static void Main(string[] args)
3232
Demo6();
3333
Demo7();
3434
Demo8();
35+
Demo9();
3536

3637
/* ### PERFORMANCE TESTS ### */
3738
// # Use tests in this section to test the performance of PicoXLSX
@@ -306,5 +307,69 @@ private static void Demo8()
306307
workbook.Save(); // Save the workbook
307308
}
308309

310+
/// <summary>
311+
/// This demo shows the usage of basic Excel formulas
312+
/// </summary>
313+
private static void Demo9()
314+
{
315+
Workbook workbook = new Workbook("test9.xlsx", "sheet1"); // Create a new workbook
316+
List<object> numbers = new List<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 = new List<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+
Cell c; // Create an empty cell object (reusable)
328+
c = Cell.BasicFormulas.Average(new Cell.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(new Cell.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(new Cell.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(new Cell.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(new Cell.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(new Cell.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(new Cell.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(new Cell.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, new Cell.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], new Cell.Address("B4"), workbook.Worksheets[0], new Cell.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], new Cell.Range("A2:A10")); // Define a median formula in worksheet1
369+
workbook.WS.Value(c); // Add the formula to the worksheet
370+
371+
workbook.Save(); // Save the workbook
372+
}
373+
309374
}
310-
}
375+
}

0 commit comments

Comments
 (0)