Skip to content

Commit 20e008d

Browse files
Update v2.2.0
1 parent cc442d8 commit 20e008d

File tree

536 files changed

+2128
-1627
lines changed

Some content is hidden

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

536 files changed

+2128
-1627
lines changed

Changelog.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
# Change Log
22

3+
## v2.2.0
4+
---
5+
Release Date: **10.12.2017**
6+
7+
- Added Shortener class (WS) in workbook for quicker writing of data / formulas
8+
- Updated descriptions
9+
- Added full NuGet support
10+
311
## v2.1.1
412
---
513
Release Date: **07.12.2017**
614

715
- Documentation Update
816
- Fixed version number of the assembly
9-
- Preparation for Nuget release
17+
- Preparation for NuGet release
1018

1119
## v2.1.0
1220
---

Demo/Program.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Program
2222
static void Main(string[] args)
2323
{
2424
BasicDemo();
25+
ShortenerDemo();
2526
StreamDemo();
2627
Demo1();
2728
Demo2();
@@ -52,6 +53,25 @@ private static void BasicDemo()
5253
workbook.Save();
5354
}
5455

56+
/// <summary>
57+
/// This method show the shortened style of writing cells
58+
/// </summary>
59+
private static void ShortenerDemo()
60+
{
61+
Workbook wb = new Workbook("shortenerDemo.xlsx", "Sheet1"); // Create a workbook (important: A worksheet must be created as well)
62+
wb.WS.Value("Some Text"); // Add cell A1
63+
wb.WS.Value(58.55, Style.BasicStyles.DoubleUnderline); // Add a formated value to cell B1
64+
wb.WS.Right(2); // Move to cell E1
65+
wb.WS.Value(true); // Add cell E1
66+
wb.AddWorksheet("Sheet2"); // Add a new worksheet
67+
wb.CurrentWorksheet.CurrentCellDirection = Worksheet.CellDirection.RowToRow; // Change the cell direction
68+
wb.WS.Value("This is another text"); // Add cell A1
69+
wb.WS.Formula("=A1"); // Add a formula in Cell A2
70+
wb.WS.Down(); // Go to cell A4
71+
wb.WS.Value("Formated Text", Style.BasicStyles.Bold); // Add a formated value to cell A4
72+
wb.Save(); // Save the workbook
73+
}
74+
5575
/// <summary>
5676
/// This method shows how to save a workbook as stream
5777
/// </summary>

Executable/Debug/PicoXLSX.XML

Lines changed: 771 additions & 693 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Executable/Debug/PicoXLSX.dll

4 KB
Binary file not shown.

Executable/Documentation.chm

25.5 KB
Binary file not shown.

Executable/Release/PicoXLSX.dll

3.5 KB
Binary file not shown.

PicoXLSX/Properties/AssemblyInfo.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// General Information about an assembly is controlled through the following
77
// set of attributes. Change these attribute values to modify the information
88
// associated with an assembly.
9-
[assembly: AssemblyTitle ("PicoXLSX")]
10-
[assembly: AssemblyDescription ("PicoXLSX is a library to generate XLSX files in an easy and native way")]
9+
[assembly: AssemblyTitle ("PicoXLSX")]
10+
[assembly: AssemblyDescription("PicoXLSX is a library to generate Microsoft Excel files (XLSX) in an easy and native way")]
1111
[assembly: AssemblyConfiguration ("")]
1212
[assembly: AssemblyCompany("Raphael Stoeckli")]
1313
[assembly: AssemblyProduct ("PicoXLSX")]
@@ -29,6 +29,6 @@
2929
//
3030
// You can specify all the values or you can default the Build and Revision Numbers
3131
// by using the '*' as shown below:
32-
// [assembly: AssemblyVersion("1.0.*")]
33-
[assembly: AssemblyVersion("2.1.1")]
34-
[assembly: AssemblyFileVersion("2.1.1")]
32+
// [assembly: AssemblyVersion("1.0.*")]
33+
[assembly: AssemblyVersion("2.2.0")]
34+
[assembly: AssemblyFileVersion("2.2.0")]

PicoXLSX/Workbook.cs

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,21 @@ public class Workbook
3535
private bool lockWindowsIfProtected;
3636
private bool lockStructureIfProtected;
3737
private int selectedWorksheet;
38+
private Shortener shortener;
3839
#endregion
3940

4041
#region properties
42+
43+
44+
/// <summary>
45+
/// Shortener object for the current worksheet
46+
/// </summary>
47+
public Shortener WS
48+
{
49+
get { return shortener; }
50+
}
51+
52+
4153
/// <summary>
4254
/// Gets the current worksheet
4355
/// </summary>
@@ -230,6 +242,7 @@ public void AddWorksheet(string name)
230242
Worksheet newWs = new Worksheet(name, number, this);
231243
this.currentWorksheet = newWs;
232244
this.worksheets.Add(newWs);
245+
this.shortener.SetCurrentWorksheet(this.currentWorksheet);
233246
}
234247

235248
/// <summary>
@@ -287,6 +300,7 @@ private void Init()
287300
borderStyle.CurrentFill = Style.BasicStyles.DottedFill_0_125.CurrentFill;
288301
this.styleManager.AddStyle(borderStyle);
289302
this.workbookMetadata = new Metadata();
303+
this.shortener = new Shortener();
290304
}
291305

292306

@@ -590,5 +604,130 @@ public void SetSelectedWorksheet(Worksheet worksheet)
590604
}
591605

592606
#endregion
607+
608+
#region sub-classes
609+
610+
/// <summary>
611+
/// Class to provide access to the current worksheet with a shortened syntax
612+
/// </summary>
613+
public class Shortener
614+
{
615+
private Worksheet currentWorksheet;
616+
617+
/// <summary>
618+
/// Default constructor
619+
/// </summary>
620+
public Shortener()
621+
{ }
622+
623+
/// <summary>
624+
/// Sets the worksheet accessed by the shortener
625+
/// </summary>
626+
/// <param name="worksheet"></param>
627+
public void SetCurrentWorksheet(Worksheet worksheet)
628+
{
629+
this.currentWorksheet = worksheet;
630+
}
631+
632+
/// <summary>
633+
/// Sets a value into the current cell and moves the cursor to the next cell (column or row depending on the defined cell direction)
634+
/// </summary>
635+
/// <exception cref="WorksheetException">Throws a WorksheetException if no worksheet was defined</exception>
636+
/// <param name="value">Value to set</param>
637+
public void Value(object value)
638+
{
639+
NullCheck();
640+
this.currentWorksheet.AddNextCell(value);
641+
}
642+
643+
/// <summary>
644+
/// Sets a value with style into the current cell and moves the cursor to the next cell (column or row depending on the defined cell direction)
645+
/// </summary>
646+
/// <exception cref="WorksheetException">Throws a WorksheetException if no worksheet was defined</exception>
647+
/// <param name="value">Value to set</param>
648+
/// <param name="style">Style to apply</param>
649+
public void Value(object value, Style style)
650+
{
651+
NullCheck();
652+
this.currentWorksheet.AddNextCell(value, style);
653+
}
654+
655+
/// <summary>
656+
/// Sets a formula into the current cell and moves the cursor to the next cell (column or row depending on the defined cell direction)
657+
/// </summary>
658+
/// <exception cref="WorksheetException">Throws a WorksheetException if no worksheet was defined</exception>
659+
/// <param name="formula">Formula to set</param>
660+
public void Formula(string formula)
661+
{
662+
NullCheck();
663+
this.currentWorksheet.AddNextCellFormula(formula);
664+
}
665+
666+
/// <summary>
667+
/// Sets a formula with style into the current cell and moves the cursor to the next cell (column or row depending on the defined cell direction)
668+
/// </summary>
669+
/// <exception cref="WorksheetException">Throws a WorksheetException if no worksheet was defined</exception>
670+
/// <param name="formula">Formula to set</param>
671+
/// <param name="style">Style to apply</param>
672+
public void Formula(string formula, Style style)
673+
{
674+
NullCheck();
675+
this.currentWorksheet.AddNextCellFormula(formula, style);
676+
}
677+
678+
/// <summary>
679+
/// Moves the cursor one row down
680+
/// </summary>
681+
public void Down()
682+
{
683+
NullCheck();
684+
this.currentWorksheet.GoToNextRow();
685+
}
686+
687+
/// <summary>
688+
/// Moves the cursor the number of defined rows down
689+
/// </summary>
690+
/// <param name="numberOfRows">Number of rows to move</param>
691+
public void Down(int numberOfRows)
692+
{
693+
NullCheck();
694+
this.currentWorksheet.GoToNextRow(numberOfRows);
695+
}
696+
697+
/// <summary>
698+
/// Moves the cursor one column to the right
699+
/// </summary>
700+
public void Right()
701+
{
702+
NullCheck();
703+
this.currentWorksheet.GoToNextColumn();
704+
}
705+
706+
/// <summary>
707+
/// Moves the cursor the number of defined columns to the right
708+
/// </summary>
709+
/// <param name="numberOfColumns">Number of columns to move</param>
710+
public void Right(int numberOfColumns)
711+
{
712+
NullCheck();
713+
this.currentWorksheet.GoToNextColumn(numberOfColumns);
714+
}
715+
716+
/// <summary>
717+
/// Internal method to check whether the worksheet is null
718+
/// </summary>
719+
private void NullCheck()
720+
{
721+
if (this.currentWorksheet == null)
722+
{
723+
throw new WorksheetException("UndefinedWorksheetException", "No worksheet was defined");
724+
}
725+
}
726+
727+
728+
}
729+
730+
#endregion
731+
593732
}
594733
}

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
![PicoXLSX](https://rabanti-github.github.io/PicoXLSX/icons/PicoXLSX.png)
33

44

5-
PicoXLSX is a small .NET / C# library to create XLSX files (Microsoft Excel 2007 or newer) in an easy and native way
5+
PicoXLSX is a small .NET library written in C#, to create Microsoft Excel files in the XLSX format (Microsoft Excel 2007 or newer) in an easy and native way
66
* **No dependencies** (\*
77
* No need for an installation of Microsoft Office
88
* No need for Office interop libraries
@@ -44,7 +44,17 @@ Simply place the PicoXLSX DLL into your .NET project and add a reference (in VS
4444
Place all .CS files from the PicoXLSX source folder into your project. You can place them into a sub-folder if you wish. The files contains definitions for workbooks, worksheets, cells, styles, meta-data, low level methods and exceptions.
4545

4646
# Usage
47-
## Quick Start
47+
## Quick Start (shortened syntax)
48+
```
49+
Workbook workbook = new Workbook("myWorkbook.xlsx", "Sheet1"); // Create new workbook with a worksheet called Sheet1
50+
workbook.WS.Value("Some Data"); // Add cell A1
51+
workbook.WS.Formula("=A1"); // Add formula to cell B1
52+
workbook.WS.Down(); // Go to row 2
53+
workbook.WS.Value(DateTime.Now, Style.BasicStyles.Bold); // Add formated value to cell A2
54+
workbook.Save(); // Save the workbook as myWorkbook.xlsx
55+
```
56+
57+
## Quick Start (regular syntax)
4858
```
4959
Workbook workbook = new Workbook("myWorkbook.xlsx", "Sheet1"); // Create new workbook with a worksheet called Sheet1
5060
workbook.CurrentWorksheet.AddNextCell("Some Data"); // Add cell A1
@@ -58,6 +68,6 @@ Place all .CS files from the PicoXLSX source folder into your project. You can p
5868
See the full **API-Documentation** at: [https://rabanti-github.github.io/PicoXLSX/](https://rabanti-github.github.io/PicoXLSX/).
5969

6070

61-
The [Demo project](https://github.com/rabanti-github/PicoXLSX/tree/master/Demo) contains ten simple use cases. You can find also the full documentation in the [Documentation-Folder](https://github.com/rabanti-github/PicoXLSX/tree/master/Documentation) or as C# documentation in the .CS files.
71+
The [Demo project](https://github.com/rabanti-github/PicoXLSX/tree/master/Demo) contains eleven simple use cases. You can find also the full documentation in the [Documentation-Folder](https://github.com/rabanti-github/PicoXLSX/tree/master/Documentation) or as C# documentation in the .CS files.
6272

6373
See also: [Getting started in the Wiki](https://github.com/rabanti-github/PicoXLSX/wiki/Getting-started)

docs/Documentation.chm

25.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)