diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLAlignment.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLAlignment.cs
index 36af17d..0036ff4 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLAlignment.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLAlignment.cs
@@ -13,16 +13,15 @@
this.container = container;
if (d != null)
{
- Horizontal = d.Horizontal;
- Vertical = d.Vertical;
- Indent = d.Indent;
- JustifyLastLine = d.JustifyLastLine;
- ReadingOrder = d.ReadingOrder;
- RelativeIndent = d.RelativeIndent;
- ShrinkToFit = d.ShrinkToFit;
- TextRotation = d.TextRotation;
- WrapText = d.WrapText;
- TopToBottom = d.TopToBottom;
+ horizontal = d.Horizontal;
+ vertical = d.Vertical;
+ indent = d.Indent;
+ justifyLastLine = d.JustifyLastLine;
+ readingOrder = d.ReadingOrder;
+ relativeIndent = d.RelativeIndent;
+ shrinkToFit = d.ShrinkToFit;
+ textRotation = d.TextRotation;
+ wrapText = d.WrapText;
}
}
@@ -198,7 +197,6 @@
}
}
- private Boolean topToBottom;
public Boolean TopToBottom
{
get
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLBorder.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLBorder.cs
index 8178777..01e7fe0 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLBorder.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLBorder.cs
@@ -13,18 +13,18 @@
this.container = container;
if (defaultBorder != null)
{
- LeftBorder = defaultBorder.LeftBorder;
- LeftBorderColor = defaultBorder.LeftBorderColor;
- RightBorder = defaultBorder.RightBorder;
- RightBorderColor = defaultBorder.RightBorderColor;
- TopBorder = defaultBorder.TopBorder;
- TopBorderColor = defaultBorder.TopBorderColor;
- BottomBorder = defaultBorder.BottomBorder;
- BottomBorderColor = defaultBorder.BottomBorderColor;
- DiagonalBorder = defaultBorder.DiagonalBorder;
- DiagonalBorderColor = defaultBorder.DiagonalBorderColor;
- DiagonalUp = defaultBorder.DiagonalUp;
- DiagonalDown = defaultBorder.DiagonalDown;
+ leftBorder = defaultBorder.LeftBorder;
+ leftBorderColor = defaultBorder.LeftBorderColor;
+ rightBorder = defaultBorder.RightBorder;
+ rightBorderColor = defaultBorder.RightBorderColor;
+ topBorder = defaultBorder.TopBorder;
+ topBorderColor = defaultBorder.TopBorderColor;
+ bottomBorder = defaultBorder.BottomBorder;
+ bottomBorderColor = defaultBorder.BottomBorderColor;
+ diagonalBorder = defaultBorder.DiagonalBorder;
+ diagonalBorderColor = defaultBorder.DiagonalBorderColor;
+ diagonalUp = defaultBorder.DiagonalUp;
+ diagonalDown = defaultBorder.DiagonalDown;
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFill.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFill.cs
index 8d40bb9..6f29a53 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFill.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFill.cs
@@ -89,9 +89,9 @@
this.container = container;
if (defaultFill != null)
{
- PatternType = defaultFill.PatternType;
- PatternColor = defaultFill.PatternColor;
- PatternBackgroundColor = defaultFill.PatternBackgroundColor;
+ patternType = defaultFill.PatternType;
+ patternColor = defaultFill.PatternColor;
+ patternBackgroundColor = defaultFill.PatternBackgroundColor;
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFont.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFont.cs
index d300433..2e39f4d 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFont.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFont.cs
@@ -14,16 +14,16 @@
this.container = container;
if (defaultFont != null)
{
- Bold = defaultFont.Bold;
- Italic = defaultFont.Italic;
- Underline = defaultFont.Underline;
- Strikethrough = defaultFont.Strikethrough;
- VerticalAlignment = defaultFont.VerticalAlignment;
- Shadow = defaultFont.Shadow;
- FontSize = defaultFont.FontSize;
- FontColor = defaultFont.FontColor;
- FontName = defaultFont.FontName;
- FontFamilyNumbering = defaultFont.FontFamilyNumbering;
+ bold = defaultFont.Bold;
+ italic = defaultFont.Italic;
+ underline = defaultFont.Underline;
+ strikethrough = defaultFont.Strikethrough;
+ verticalAlignment = defaultFont.VerticalAlignment;
+ shadow = defaultFont.Shadow;
+ fontSize = defaultFont.FontSize;
+ fontColor = defaultFont.FontColor;
+ fontName = defaultFont.FontName;
+ fontFamilyNumbering = defaultFont.FontFamilyNumbering;
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLNumberFormat.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLNumberFormat.cs
index cbfd052..378a75a 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLNumberFormat.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLNumberFormat.cs
@@ -57,9 +57,9 @@
if (defaultNumberFormat != null)
{
if (defaultNumberFormat.NumberFormatId >= 0)
- NumberFormatId = defaultNumberFormat.NumberFormatId;
+ numberFormatId = defaultNumberFormat.NumberFormatId;
else
- Format = defaultNumberFormat.Format;
+ format = defaultNumberFormat.Format;
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLStyle.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLStyle.cs
index b48a3a3..8e3ac2e 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLStyle.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLStyle.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using OX.Copyable;
namespace ClosedXML.Excel.Style
{
@@ -12,16 +11,19 @@
{
if (initialStyle != null)
{
- //Font = new XLFont(container, initialStyle.Font);
- Font = (IXLFont)initialStyle.Font.Copy();
- Alignment = (IXLAlignment)initialStyle.Alignment.Copy();
- Border = (IXLBorder)initialStyle.Border.Copy();
- Fill = (IXLFill)initialStyle.Fill.Copy();
- NumberFormat = (IXLNumberFormat)initialStyle.NumberFormat.Copy();
+ Font = new XLFont(container, initialStyle.Font);
+ Alignment = new XLAlignment(container, initialStyle.Alignment);
+ Border = new XLBorder(container, initialStyle.Border);
+ Fill = new XLFill(container, initialStyle.Fill);
+ NumberFormat = new XLNumberFormat(container, initialStyle.NumberFormat);
}
else
{
- //Font = new XLFont(container);
+ Font = new XLFont(container);
+ Alignment = new XLAlignment(container);
+ Border = new XLBorder(container);
+ Fill = new XLFill(container);
+ NumberFormat = new XLNumberFormat(container);
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLCell.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLCell.cs
index 7ce2db6..7f56f30 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/XLCell.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLCell.cs
@@ -29,18 +29,18 @@
String val = value;
Double dTest;
- //DateTime dtTest;
+ DateTime dtTest;
Boolean bTest;
if (Double.TryParse(val, out dTest))
{
DataType = XLCellValues.Number;
}
- //else if (DateTime.TryParse(val, out dtTest))
- //{
- // DataType = XLCellValues.DateTime;
- // Style.NumberFormat = new OPNumberFormat(14);
- // val = dtTest.ToOADate().ToString();
- //}
+ else if (DateTime.TryParse(val, out dtTest))
+ {
+ DataType = XLCellValues.DateTime;
+ Style.NumberFormat.NumberFormatId = 14;
+ val = dtTest.ToOADate().ToString();
+ }
else if (Boolean.TryParse(val, out bTest))
{
DataType = XLCellValues.Boolean;
diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/BasicTable.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/BasicTable.cs
index 621bb45..566c7e8 100644
--- a/ClosedXML/ClosedXML/ClosedXML_Examples/BasicTable.cs
+++ b/ClosedXML/ClosedXML/ClosedXML_Examples/BasicTable.cs
@@ -4,6 +4,7 @@
using System.Text;
using ClosedXML.Excel;
using ClosedXML.Excel.Style;
+using System.Drawing;
namespace ClosedXML_Examples
{
@@ -11,9 +12,13 @@
{
public void Create(String filePath)
{
+ // Creating a new workbook
var workbook = new XLWorkbook();
+
+ //Adding a worksheet
var ws = workbook.Worksheets.Add("Contacts");
+ //Adding text
//First Names
ws.Cell("A1").Value = "FName";
ws.Cell("A2").Value = "John";
@@ -24,6 +29,8 @@
ws.Cell("B2").Value = "Galt";
ws.Cell("B3").Value = "Rearden";
ws.Cell("B4").Value = "Taggart";
+
+ //Adding more data types
//Is an outcast?
ws.Cell("C1").Value = "Outcast";
ws.Cell("C2").Value = true.ToString();
@@ -40,19 +47,24 @@
ws.Cell("E3").Value = "40000";
ws.Cell("E4").Value = "10000";
- //var rngDates = ws.Range("D2:D4");
- //var rngNumbers = ws.Range("E2:E4");
+ //Defining ranges
+ var rngDates = ws.Range("D2:D4");
+ var rngNumbers = ws.Range("E2:E4");
- //rngDates.Style.NumberFormat.Format = "mm-dd-yy";
- //rngNumbers.Style.NumberFormat.Format = "$ #,##0";
+ //Formatting dates and numbers
+ rngDates.Style.NumberFormat.Format = "mm-dd-yyyy";
+ rngNumbers.Style.NumberFormat.Format = "$ #,##0";
- //var rngHeaders = ws.Range("A1:E1");
- //rngHeaders.Style.Font.Bold = true;
- //rngHeaders.Style.Fill.BackgroundColor = "6BE8FF";
+ //Formatting headers
+ var rngHeaders = ws.Range("A1:E1");
+ rngHeaders.Style.Font.Bold = true;
+ rngHeaders.Style.Fill.BackgroundColor = Color.Aqua;
- //var rngTable = ws.Range("A1:E4");
- //rngTable.Style.Border.BottomBorder = XLBorderStyleValues.Thin;
+ //Adding grid lines
+ var rngTable = ws.Range("A1:E4");
+ rngTable.Style.Border.BottomBorder = XLBorderStyleValues.Thin;
+ //Saving the workbook
workbook.SaveAs(filePath);
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/ClosedXML_Examples.csproj b/ClosedXML/ClosedXML/ClosedXML_Examples/ClosedXML_Examples.csproj
index 5cd4bfc..90514ac 100644
--- a/ClosedXML/ClosedXML/ClosedXML_Examples/ClosedXML_Examples.csproj
+++ b/ClosedXML/ClosedXML/ClosedXML_Examples/ClosedXML_Examples.csproj
@@ -52,6 +52,7 @@
+
diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/Program.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/Program.cs
index 48cdad6..d9d209b 100644
--- a/ClosedXML/ClosedXML/ClosedXML_Examples/Program.cs
+++ b/ClosedXML/ClosedXML/ClosedXML_Examples/Program.cs
@@ -10,21 +10,9 @@
{
static void Main(string[] args)
{
- //var helloWorld = new HelloWorld();
- //helloWorld.Create(@"c:\HelloWorld.xlsx");
-
- //new StyleFont().Create(@"c:\styleFont.xlsx");
-
- //new StyleFill().Create(@"c:\styleFill.xlsx");
-
- //new StyleBorder().Create(@"c:\styleBorder.xlsx");
-
- //new StyleAlignment().Create(@"c:\styleAlignment.xlsx");
-
- new StyleNumberFormat().Create(@"c:\styleNumberFormat.xlsx");
-
- //var basicTable = new BasicTable();
- //basicTable.Create(@"c:\BasicTable.xlsx");
+ new HelloWorld().Create(@"c:\HelloWorld.xlsx");
+ new BasicTable().Create(@"c:\BasicTable.xlsx");
+ new StyleExamples().Create();
}
}
}
\ No newline at end of file
diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/StyleExamples.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/StyleExamples.cs
new file mode 100644
index 0000000..487607f
--- /dev/null
+++ b/ClosedXML/ClosedXML/ClosedXML_Examples/StyleExamples.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ClosedXML.Excel;
+using ClosedXML_Examples.Styles;
+
+namespace ClosedXML_Examples
+{
+ public class StyleExamples
+ {
+ #region Variables
+
+ // Public
+
+ // Private
+
+
+ #endregion
+
+ #region Properties
+
+ // Public
+
+ // Private
+
+ // Override
+
+
+ #endregion
+
+ #region Constructors
+
+ // Public
+ public StyleExamples()
+ {
+
+ }
+
+
+ // Private
+
+
+ #endregion
+
+ #region Events
+
+ // Public
+
+ // Private
+
+ // Override
+
+
+ #endregion
+
+ #region Methods
+
+ // Public
+ public void Create()
+ {
+ new StyleFont().Create(@"c:\styleFont.xlsx");
+ new StyleFill().Create(@"c:\styleFill.xlsx");
+ new StyleBorder().Create(@"c:\styleBorder.xlsx");
+ new StyleAlignment().Create(@"c:\styleAlignment.xlsx");
+ new StyleNumberFormat().Create(@"c:\styleNumberFormat.xlsx");
+ }
+
+ // Private
+
+ // Override
+
+
+ #endregion
+ }
+}