diff --git a/ClosedXML/ClosedXML/ClosedXML.sln b/ClosedXML/ClosedXML/ClosedXML.sln new file mode 100644 index 0000000..086fadf --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML.sln @@ -0,0 +1,79 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClosedXML", "ClosedXML\ClosedXML.csproj", "{BD5E6BFE-E837-4A35-BCA9-39667D873A20}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClosedXML_Sandbox", "ClosedXML_Sandbox\ClosedXML_Sandbox.csproj", "{38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5C94E22C-85AA-48FD-B082-CF929FFC6C31}" + ProjectSection(SolutionItems) = preProject + ClosedXML.vsmdi = ClosedXML.vsmdi + Local.testsettings = Local.testsettings + TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClosedXML_Examples", "ClosedXML_Examples\ClosedXML_Examples.csproj", "{03A518D0-1CB7-488E-861C-C4E782B27A46}" +EndProject +Global + GlobalSection(TeamFoundationVersionControl) = preSolution + SccNumberOfProjects = 4 + SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} + SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs09 + SccLocalPath0 = . + SccProjectUniqueName1 = ClosedXML\\ClosedXML.csproj + SccProjectName1 = ClosedXML + SccLocalPath1 = ClosedXML + SccProjectUniqueName2 = ClosedXML_Examples\\ClosedXML_Examples.csproj + SccProjectName2 = ClosedXML_Examples + SccLocalPath2 = ClosedXML_Examples + SccProjectUniqueName3 = ClosedXML_Sandbox\\ClosedXML_Sandbox.csproj + SccProjectName3 = ClosedXML_Sandbox + SccLocalPath3 = ClosedXML_Sandbox + EndGlobalSection + GlobalSection(TestCaseManagementSettings) = postSolution + CategoryFile = ClosedXML.vsmdi + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BD5E6BFE-E837-4A35-BCA9-39667D873A20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD5E6BFE-E837-4A35-BCA9-39667D873A20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD5E6BFE-E837-4A35-BCA9-39667D873A20}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BD5E6BFE-E837-4A35-BCA9-39667D873A20}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {BD5E6BFE-E837-4A35-BCA9-39667D873A20}.Debug|x86.ActiveCfg = Debug|Any CPU + {BD5E6BFE-E837-4A35-BCA9-39667D873A20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD5E6BFE-E837-4A35-BCA9-39667D873A20}.Release|Any CPU.Build.0 = Release|Any CPU + {BD5E6BFE-E837-4A35-BCA9-39667D873A20}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {BD5E6BFE-E837-4A35-BCA9-39667D873A20}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {BD5E6BFE-E837-4A35-BCA9-39667D873A20}.Release|x86.ActiveCfg = Release|Any CPU + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}.Debug|Any CPU.ActiveCfg = Debug|x86 + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}.Debug|x86.ActiveCfg = Debug|x86 + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}.Debug|x86.Build.0 = Debug|x86 + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}.Release|Any CPU.ActiveCfg = Release|x86 + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}.Release|Mixed Platforms.Build.0 = Release|x86 + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}.Release|x86.ActiveCfg = Release|x86 + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB}.Release|x86.Build.0 = Release|x86 + {03A518D0-1CB7-488E-861C-C4E782B27A46}.Debug|Any CPU.ActiveCfg = Debug|x86 + {03A518D0-1CB7-488E-861C-C4E782B27A46}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {03A518D0-1CB7-488E-861C-C4E782B27A46}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {03A518D0-1CB7-488E-861C-C4E782B27A46}.Debug|x86.ActiveCfg = Debug|x86 + {03A518D0-1CB7-488E-861C-C4E782B27A46}.Debug|x86.Build.0 = Debug|x86 + {03A518D0-1CB7-488E-861C-C4E782B27A46}.Release|Any CPU.ActiveCfg = Release|x86 + {03A518D0-1CB7-488E-861C-C4E782B27A46}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {03A518D0-1CB7-488E-861C-C4E782B27A46}.Release|Mixed Platforms.Build.0 = Release|x86 + {03A518D0-1CB7-488E-861C-C4E782B27A46}.Release|x86.ActiveCfg = Release|x86 + {03A518D0-1CB7-488E-861C-C4E782B27A46}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ClosedXML/ClosedXML/ClosedXML.vsmdi b/ClosedXML/ClosedXML/ClosedXML.vsmdi new file mode 100644 index 0000000..2acf62a --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML.vsmdi @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ClosedXML/ClosedXML/ClosedXML.vssscc b/ClosedXML/ClosedXML/ClosedXML.vssscc new file mode 100644 index 0000000..794f014 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML.vssscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" +} diff --git a/ClosedXML/ClosedXML/ClosedXML/ClosedXML.csproj b/ClosedXML/ClosedXML/ClosedXML/ClosedXML.csproj new file mode 100644 index 0000000..a5e8c9b --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/ClosedXML.csproj @@ -0,0 +1,97 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {BD5E6BFE-E837-4A35-BCA9-39667D873A20} + Library + Properties + ClosedXML + ClosedXML + v4.0 + 512 + SAK + SAK + SAK + SAK + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + False + ..\..\..\My Documents\Code\OX.Copyable\havard-copyable-fd863c3\OX.Copyable\bin\Release\OX.Copyable.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ClosedXML/ClosedXML/ClosedXML/ClosedXML.csproj.vspscc b/ClosedXML/ClosedXML/ClosedXML/ClosedXML.csproj.vspscc new file mode 100644 index 0000000..feffdec --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/ClosedXML.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/IXLAddress.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLAddress.cs new file mode 100644 index 0000000..e232ae8 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLAddress.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel +{ + public interface IXLAddress : IEqualityComparer, IEquatable, IComparable, IComparable + { + Int32 Row { get; } + Int32 Column { get; } + String ColumnLetter { get; } + } + + public static class XLAddressMethods + { + + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/IXLCell.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLCell.cs new file mode 100644 index 0000000..7561b9f --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLCell.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel.Style; + +namespace ClosedXML.Excel +{ + public enum XLCellValues { SharedString, Number, Boolean, DateTime } + + public interface IXLCell: IXLStylized + { + Boolean Initialized { get; } + String Value { get; set; } + IXLAddress Address { get; } + XLCellValues DataType { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/IXLColumn.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLColumn.cs new file mode 100644 index 0000000..cde3796 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLColumn.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel +{ + public interface IXLColumn: IXLRange + { + Int32 Width { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/IXLRange.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLRange.cs new file mode 100644 index 0000000..671fe45 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLRange.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel.Style; + +namespace ClosedXML.Excel +{ + public interface IXLRange: IXLStylized + { + Dictionary CellsCollection { get; } + + IXLAddress FirstCellAddress { get; } + IXLAddress LastCellAddress { get; } + IXLRange Row(Int32 row); + IXLRange Column(Int32 column); + IXLRange Column(String column); + } + + public static class XLRangeMethods + { + public static IXLCell FirstCell(this IXLRange range) + { + return range.Cell(1, 1); + } + public static IXLCell LastCell(this IXLRange range) + { + return range.Cell(range.RowCount(), range.ColumnCount()); + } + + public static IXLCell Cell(this IXLRange range, IXLAddress cellAddressInRange) + { + IXLAddress absoluteAddress = (XLAddress)cellAddressInRange + (XLAddress)range.FirstCellAddress - 1; + if (range.CellsCollection.ContainsKey(absoluteAddress)) + { + return range.CellsCollection[absoluteAddress]; + } + else + { + var newCell = new XLCell(absoluteAddress, range.Style); + range.CellsCollection.Add(absoluteAddress, newCell); + return newCell; + } + } + public static IXLCell Cell(this IXLRange range, Int32 row, Int32 column) + { + return range.Cell(new XLAddress(row, column)); + } + public static IXLCell Cell(this IXLRange range, Int32 row, String column) + { + return range.Cell(new XLAddress(row, column)); + } + public static IXLCell Cell(this IXLRange range, String cellAddressInRange) + { + return range.Cell(new XLAddress(cellAddressInRange)); + } + + public static Int32 RowCount(this IXLRange range) + { + return range.LastCellAddress.Row - range.FirstCellAddress.Row + 1; + } + public static Int32 ColumnCount(this IXLRange range) + { + return range.LastCellAddress.Column - range.FirstCellAddress.Column + 1; + } + + public static IXLRange Range(this IXLRange range, String rangeAddress) + { + String[] arrRange = rangeAddress.Split(':'); + return range.Range(arrRange[0], arrRange[1]); + } + public static IXLRange Range(this IXLRange range, String firstCellAddress, String lastCellAddress) + { + return range.Range(new XLAddress(firstCellAddress), new XLAddress(lastCellAddress)); + } + public static IXLRange Range(this IXLRange range, IXLAddress firstCellAddress, IXLAddress lastCellAddress) + { + return new XLRange( + (XLAddress)firstCellAddress + (XLAddress)range.FirstCellAddress - 1, + (XLAddress)lastCellAddress + (XLAddress)range.FirstCellAddress - 1, + range.CellsCollection + ); + } + public static IXLRange Range(this IXLRange range, IXLCell firstCell, IXLCell lastCell) + { + return range.Range(firstCell.Address, lastCell.Address); + } + + + public static IEnumerable Cells(this IXLRange range) + { + foreach(var row in Enumerable.Range(1, range.RowCount())) + { + foreach(var column in Enumerable.Range(1, range.ColumnCount())) + { + yield return range.Cell(row, column); + } + } + } + + + } +} + diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/IXLWorkbook.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLWorkbook.cs new file mode 100644 index 0000000..e4b3074 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLWorkbook.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel.Style; + +namespace ClosedXML.Excel +{ + public interface IXLWorkbook + { + IXLWorksheets Worksheets { get; } + String Name { get; } + String FullName { get; } + void SaveAs(String file, Boolean overwrite = false); + //IXLStyle DefaultStyle { get; set; } + + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/IXLWorksheet.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLWorksheet.cs new file mode 100644 index 0000000..8b4274a --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLWorksheet.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel +{ + public interface IXLWorksheet: IXLRange + { + new IXLColumn Column(Int32 column); + new IXLColumn Column(String column); + + String Name { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/IXLWorksheets.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLWorksheets.cs new file mode 100644 index 0000000..e3826b9 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLWorksheets.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel +{ + public interface IXLWorksheets: IEnumerable + { + IXLWorksheet GetWorksheet(String sheetName); + IXLWorksheet GetWorksheet(Int32 sheetIndex); + IXLWorksheet Add(String sheetName); + void Delete(String sheetName); + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLAlignment.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLAlignment.cs new file mode 100644 index 0000000..f1d4715 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLAlignment.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel.Style +{ + public enum XLAlignmentReadingOrderValues + { + ContextDependent, + LeftToRight, + RightToLeft + } + + public enum XLAlignmentHorizontalValues + { + Center, + CenterContinuous, + Distributed, + Fill, + General, + Justify, + Left, + Right + } + + public enum XLAlignmentVerticalValues + { + Bottom, + Center, + Distributed, + Justify, + Top + } + + public interface IXLAlignment + { + XLAlignmentHorizontalValues Horizontal { get; set; } + + XLAlignmentVerticalValues Vertical { get; set; } + + UInt32 Indent { get; set; } + + Boolean JustifyLastLine { get; set; } + + XLAlignmentReadingOrderValues ReadingOrder { get; set; } + + Int32 RelativeIndent { get; set; } + + Boolean ShrinkToFit { get; set; } + + UInt32 TextRotation { get; set; } + + Boolean WrapText { get; set; } + + Boolean TopToBottom { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLBorder.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLBorder.cs new file mode 100644 index 0000000..fa8cb42 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLBorder.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace ClosedXML.Excel.Style +{ + public enum XLBorderStyleValues + { + DashDot, + DashDotDot, + Dashed, + Dotted, + Double, + Hair, + Medium, + MediumDashDot, + MediumDashDotDot, + MediumDashed, + None, + SlantDashDot, + Thick, + Thin + } + public interface IXLBorder + { + XLBorderStyleValues LeftBorder { get; set; } + + Color LeftBorderColor { get; set; } + + XLBorderStyleValues RightBorder { get; set; } + + Color RightBorderColor { get; set; } + + XLBorderStyleValues TopBorder { get; set; } + + Color TopBorderColor { get; set; } + + XLBorderStyleValues BottomBorder { get; set; } + + Color BottomBorderColor { get; set; } + + Boolean DiagonalUp { get; set; } + + Boolean DiagonalDown { get; set; } + + XLBorderStyleValues DiagonalBorder { get; set; } + + Color DiagonalBorderColor { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLFill.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLFill.cs new file mode 100644 index 0000000..2e50c03 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLFill.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace ClosedXML.Excel.Style +{ + public enum XLFillPatternValues + { + DarkDown, + DarkGray, + DarkGrid, + DarkHorizontal, + DarkTrellis, + DarkUp, + DarkVertical, + Gray0625, + Gray125, + LightDown, + LightGray, + LightGrid, + LightHorizontal, + LightTrellis, + LightUp, + LightVertical, + MediumGray, + None, + Solid + } + + public interface IXLFill + { + Color BackgroundColor { get; set; } + + Color PatternColor { get; set; } + + Color PatternBackgroundColor { get; set; } + + XLFillPatternValues PatternType { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLFont.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLFont.cs new file mode 100644 index 0000000..8cd2e0c --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLFont.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace ClosedXML.Excel.Style +{ + public enum XLFontUnderlineValues + { + Double, + DoubleAccounting, + None, + Single, + SingleAccounting + } + + public enum XLFontVerticalTextAlignmentValues + { + Baseline, + Subscript, + Superscript + } + + public enum XLFontFamilyNumberingValues + { + NotApplicable = 0, + Roman = 1, + Swiss = 2, + Modern = 3, + Script = 4, + Decorative = 5 + } + + public interface IXLFont + { + Boolean Bold { get; set; } + Boolean Italic { get; set; } + XLFontUnderlineValues Underline { get; set; } + Boolean Strikethrough { get; set; } + XLFontVerticalTextAlignmentValues VerticalAlignment { get; set; } + Boolean Shadow { get; set; } + Double FontSize { get; set; } + Color FontColor { get; set; } + String FontName { get; set; } + XLFontFamilyNumberingValues FontFamilyNumbering { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLNumberFormat.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLNumberFormat.cs new file mode 100644 index 0000000..7e86c68 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLNumberFormat.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel.Style +{ + public interface IXLNumberFormat + { + UInt32? NumberFormatId { get; set; } + String Format { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLStyle.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLStyle.cs new file mode 100644 index 0000000..4a45c11 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLStyle.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel.Style +{ + public interface IXLStyle + { + IXLAlignment Alignment { get; set; } + IXLBorder Border { get; set; } + IXLFill Fill { get; set; } + IXLFont Font { get; set; } + IXLNumberFormat NumberFormat { get; set; } + + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLStylized.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLStylized.cs new file mode 100644 index 0000000..c729e4c --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLStylized.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel.Style +{ + public interface IXLStylized + { + IXLStyle Style { get; set; } + IEnumerable Styles { get; } + Boolean UpdatingStyle { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLAlignment.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLAlignment.cs new file mode 100644 index 0000000..20dd845 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLAlignment.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel.Style +{ + public class XLAlignment: IXLAlignment + { + public XLAlignmentHorizontalValues Horizontal { get; set; } + + public XLAlignmentVerticalValues Vertical { get; set; } + + public uint Indent { get; set; } + + public bool JustifyLastLine { get; set; } + + public XLAlignmentReadingOrderValues ReadingOrder { get; set; } + + public int RelativeIndent { get; set; } + + public bool ShrinkToFit { get; set; } + + public uint TextRotation { get; set; } + + public bool WrapText { get; set; } + + public bool TopToBottom { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLBorder.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLBorder.cs new file mode 100644 index 0000000..7345d99 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLBorder.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +namespace ClosedXML.Excel.Style +{ + public class XLBorder: IXLBorder + { + public XLBorderStyleValues LeftBorder { get; set; } + + public Color LeftBorderColor { get; set; } + + public XLBorderStyleValues RightBorder { get; set; } + + public Color RightBorderColor { get; set; } + + public XLBorderStyleValues TopBorder { get; set; } + + public Color TopBorderColor { get; set; } + + public XLBorderStyleValues BottomBorder { get; set; } + + public Color BottomBorderColor { get; set; } + + public bool DiagonalUp { get; set; } + + public bool DiagonalDown { get; set; } + + public XLBorderStyleValues DiagonalBorder { get; set; } + + public Color DiagonalBorderColor { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFill.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFill.cs new file mode 100644 index 0000000..8d40bb9 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFill.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace ClosedXML.Excel.Style +{ + public class XLFill: IXLFill + { + #region Properties + + public Color BackgroundColor + { + get + { + return patternColor; + } + set + { + if (container != null && !container.UpdatingStyle) + { + container.Styles.ForEach(s => s.Fill.BackgroundColor = value); + } + else + { + patternType = XLFillPatternValues.Solid; + patternColor = value; + patternBackgroundColor = value; + } + } + } + + private Color patternColor; + public Color PatternColor + { + get + { + return patternColor; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Fill.PatternColor = value); + else + patternColor = value; + } + } + + private Color patternBackgroundColor; + public Color PatternBackgroundColor + { + get + { + return patternBackgroundColor; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Fill.PatternBackgroundColor = value); + else + patternBackgroundColor = value; + } + } + + private XLFillPatternValues patternType; + public XLFillPatternValues PatternType + { + get + { + return patternType; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Fill.PatternType = value); + else + patternType = value; + } + } + + #endregion + + #region Constructors + + IXLStylized container; + public XLFill(IXLStylized container, IXLFill defaultFill = null) + { + this.container = container; + if (defaultFill != null) + { + PatternType = defaultFill.PatternType; + PatternColor = defaultFill.PatternColor; + PatternBackgroundColor = defaultFill.PatternBackgroundColor; + } + } + + #endregion + + #region Overridden + + public override string ToString() + { + return BackgroundColor.ToString() + "-" + PatternType.ToString() + "-" + PatternColor.ToString(); + } + + #endregion + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFont.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFont.cs new file mode 100644 index 0000000..d300433 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLFont.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace ClosedXML.Excel.Style +{ + public class XLFont: IXLFont + { + IXLStylized container; + public XLFont(IXLStylized container, IXLFont defaultFont = null) + { + 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; + } + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append(Bold.ToString()); + sb.Append("-"); + sb.Append(Italic.ToString()); + sb.Append("-"); + sb.Append(Underline.ToString()); + sb.Append("-"); + sb.Append(Strikethrough.ToString()); + sb.Append("-"); + sb.Append(VerticalAlignment.ToString()); + sb.Append("-"); + sb.Append(Shadow.ToString()); + sb.Append("-"); + sb.Append(FontSize.ToString()); + sb.Append("-"); + sb.Append(FontColor.ToHex()); + sb.Append("-"); + sb.Append(FontName); + sb.Append("-"); + sb.Append(FontFamilyNumbering.ToString()); + return sb.ToString(); + } + + #region IXLFont Members + + private Boolean bold; + public Boolean Bold + { + get + { + return bold; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Font.Bold = value); + else + bold = value; + } + } + + private Boolean italic; + public Boolean Italic + { + get + { + return italic; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Font.Italic = value); + else + italic = value; + } + } + + private XLFontUnderlineValues underline; + public XLFontUnderlineValues Underline + { + get + { + return underline; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Font.Underline = value); + else + underline = value; + } + } + + private Boolean strikethrough; + public Boolean Strikethrough + { + get + { + return strikethrough; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Font.Strikethrough = value); + else + strikethrough = value; + } + } + + private XLFontVerticalTextAlignmentValues verticalAlignment; + public XLFontVerticalTextAlignmentValues VerticalAlignment + { + get + { + return verticalAlignment; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Font.VerticalAlignment = value); + else + verticalAlignment = value; + } + } + + private Boolean shadow; + public Boolean Shadow + { + get + { + return shadow; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Font.Shadow = value); + else + shadow = value; + } + } + + private Double fontSize; + public Double FontSize + { + get + { + return fontSize; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Font.FontSize = value); + else + fontSize = value; + } + } + + private Color fontColor; + public Color FontColor + { + get + { + return fontColor; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Font.FontColor = value); + else + fontColor = value; + } + } + + private String fontName; + public String FontName + { + get + { + return fontName; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Font.FontName = value); + else + fontName = value; + } + } + + private XLFontFamilyNumberingValues fontFamilyNumbering; + public XLFontFamilyNumberingValues FontFamilyNumbering + { + get + { + return fontFamilyNumbering; + } + set + { + if (container != null && !container.UpdatingStyle) + container.Styles.ForEach(s => s.Font.FontFamilyNumbering = value); + else + fontFamilyNumbering = value; + } + } + + #endregion + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLNumberFormat.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLNumberFormat.cs new file mode 100644 index 0000000..e3e6c35 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLNumberFormat.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel.Style +{ + public class XLNumberFormat: IXLNumberFormat + { + public uint? NumberFormatId { get; set; } + + public string Format { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLStyle.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLStyle.cs new file mode 100644 index 0000000..b48a3a3 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/XLStyle.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OX.Copyable; + +namespace ClosedXML.Excel.Style +{ + public class XLStyle: IXLStyle + { + public XLStyle(IXLStylized container, IXLStyle initialStyle = null) + { + 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(); + } + else + { + //Font = new XLFont(container); + } + } + + public IXLFont Font { get; set; } + + public IXLAlignment Alignment { get; set; } + + public IXLBorder Border { get; set; } + + public IXLFill Fill { get; set; } + + public IXLNumberFormat NumberFormat { get; set; } + + public override string ToString() + { + return + "Font:" + Font.ToString() + + " Fill:" + Fill.ToString() + + " Border:" + Border.ToString() + + " NumberFormat: " + NumberFormat.ToString() + + " Alignment: " + Alignment.ToString(); + } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLAddress.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLAddress.cs new file mode 100644 index 0000000..f5b5833 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLAddress.cs @@ -0,0 +1,271 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +namespace ClosedXML.Excel +{ + public struct XLAddress: IXLAddress + { + #region Constructors + /// + /// Initializes a new struct using R1C1 notation. + /// + /// The row number of the cell address. + /// The column number of the cell address. + public XLAddress(Int32 row, Int32 column) + { + this.row = row; + this.column = column; + this.columnLetter = GetColumnLetterFromNumber(column); + } + + /// + /// Initializes a new struct using a mixed notation. + /// + /// The row number of the cell address. + /// The column letter of the cell address. + public XLAddress(Int32 row, String columnLetter) + { + this.row = row; + this.column = GetColumnNumberFromLetter(columnLetter); + this.columnLetter = columnLetter; + } + + + /// + /// Initializes a new struct using A1 notation. + /// + /// The cell address. + public XLAddress(String cellAddressString) + { + Match m = Regex.Match(cellAddressString, @"^([a-zA-Z]+)(\d+)$"); + columnLetter = m.Groups[1].Value; + this.row = Int32.Parse(m.Groups[2].Value); + this.column = GetColumnNumberFromLetter(columnLetter); + } + + #endregion + + #region Static + + /// + /// Gets the column number of a given column letter. + /// + /// The column letter to translate into a column number. + public static Int32 GetColumnNumberFromLetter(String column) + { + Int32 intColumnLetterLength = column.Length; + Int32 retVal = 0; + for (Int32 intCount = 0; intCount < intColumnLetterLength; intCount++) + { + retVal = retVal * 26 + (column.Substring(intCount, 1).ToUpper().ToCharArray()[0] - 64); + } + return (Int32)retVal; + } + + /// + /// Gets the column letter of a given column number. + /// + /// The column number to translate into a column letter. + public static String GetColumnLetterFromNumber(Int32 column) + { + String s = String.Empty; + for ( + Int32 i = Convert.ToInt32( + Math.Log( + Convert.ToDouble( + 25 * ( + Convert.ToDouble(column) + + 1 + ) + ) + ) / Math.Log(26) + ) - 1 + ; i >= 0 + ; i-- + ) + { + Int32 x = Convert.ToInt32(Math.Pow(26, i + 1) - 1) / 25 - 1; + if (column > x) + { + s += (Char)(((column - x - 1) / Convert.ToInt32(Math.Pow(26, i))) % 26 + 65); + } + } + return s; + } + + #endregion + + #region Properties + + private Int32 row; + /// + /// Gets the row number of this address. + /// + public Int32 Row + { + get { return row; } + private set { row = value; } + } + + private Int32 column; + /// + /// Gets the column number of this address. + /// + public Int32 Column + { + get { return column; } + private set { column = value; } + } + + private String columnLetter; + /// + /// Gets the column letter(s) of this address. + /// + public String ColumnLetter + { + get { return columnLetter; } + private set { columnLetter = value; } + } + + #endregion + + #region Overrides + public override string ToString() + { + return this.columnLetter + this.row.ToString(); + } + #endregion + + #region Operator Overloads + + public static XLAddress operator +(XLAddress xlCellAddressLeft, XLAddress xlCellAddressRight) + { + return new XLAddress(xlCellAddressLeft.Row + xlCellAddressRight.Row, xlCellAddressLeft.Column + xlCellAddressRight.Column); + } + + public static XLAddress operator -(XLAddress xlCellAddressLeft, XLAddress xlCellAddressRight) + { + return new XLAddress(xlCellAddressLeft.Row - xlCellAddressRight.Row, xlCellAddressLeft.Column - xlCellAddressRight.Column); + } + + public static XLAddress operator +(XLAddress xlCellAddressLeft, Int32 right) + { + return new XLAddress(xlCellAddressLeft.Row + right, xlCellAddressLeft.Column + right); + } + + public static XLAddress operator -(XLAddress xlCellAddressLeft, Int32 right) + { + return new XLAddress(xlCellAddressLeft.Row - right, xlCellAddressLeft.Column - right); + } + + public static Boolean operator ==(XLAddress xlCellAddressLeft, XLAddress xlCellAddressRight) + { + return + xlCellAddressLeft.Row == xlCellAddressRight.Row + && xlCellAddressLeft.Column == xlCellAddressRight.Column; + } + + public static Boolean operator !=(XLAddress xlCellAddressLeft, XLAddress xlCellAddressRight) + { + return !(xlCellAddressLeft == xlCellAddressRight); + } + + public static Boolean operator >(XLAddress xlCellAddressLeft, XLAddress xlCellAddressRight) + { + return !(xlCellAddressLeft == xlCellAddressRight) + && (xlCellAddressLeft.Row > xlCellAddressRight.Row || xlCellAddressLeft.Column > xlCellAddressRight.Column); + } + + public static Boolean operator <(XLAddress xlCellAddressLeft, XLAddress xlCellAddressRight) + { + return !(xlCellAddressLeft == xlCellAddressRight) + && (xlCellAddressLeft.Row < xlCellAddressRight.Row || xlCellAddressLeft.Column < xlCellAddressRight.Column); + } + + public static Boolean operator >=(XLAddress xlCellAddressLeft, XLAddress xlCellAddressRight) + { + return xlCellAddressLeft == xlCellAddressRight || xlCellAddressLeft > xlCellAddressRight; + } + + public static Boolean operator <=(XLAddress xlCellAddressLeft, XLAddress xlCellAddressRight) + { + return xlCellAddressLeft == xlCellAddressRight || xlCellAddressLeft < xlCellAddressRight; + } + + #endregion + + #region Interface Requirements + + #region IEqualityComparer Members + + public Boolean Equals(XLAddress x, XLAddress y) + { + return x == y; + } + + public Int32 GetHashCode(XLAddress obj) + { + return obj.GetHashCode(); + } + + new public Boolean Equals(Object x, Object y) + { + return x == y; + } + + public Int32 GetHashCode(Object obj) + { + return obj.GetHashCode(); + } + + public override Int32 GetHashCode() + { + return this.ToString().GetHashCode(); + } + + #endregion + + #region IEquatable Members + + public Boolean Equals(XLAddress other) + { + return this == other; + } + + public override Boolean Equals(Object other) + { + return this == (XLAddress)other; + } + + #endregion + + #region IComparable Members + + public Int32 CompareTo(object obj) + { + var other = (XLAddress)obj; + if (this == other) + return 0; + else if (this > other) + return 1; + else + return -1; + } + + #endregion + + #region IComparable Members + + public int CompareTo(XLAddress other) + { + throw new NotImplementedException(); + } + + #endregion + + #endregion + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLCell.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLCell.cs new file mode 100644 index 0000000..7ce2db6 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLCell.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel.Style; + +namespace ClosedXML.Excel +{ + public class XLCell: IXLCell + { + public XLCell(IXLAddress address, IXLStyle defaultStyle) + { + this.Address = address; + Style = defaultStyle; + if (Style == null) Style = XLWorkbook.DefaultStyle; + } + public Boolean Initialized { get; private set; } + public IXLAddress Address { get; private set; } + + private String cellValue; + public String Value + { + get + { + return cellValue; + } + set + { + String val = value; + + Double dTest; + //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 (Boolean.TryParse(val, out bTest)) + { + DataType = XLCellValues.Boolean; + val = bTest ? "1" : "0"; + } + else + { + DataType = XLCellValues.SharedString; + } + cellValue = val; + } + } + + #region IXLStylized Members + + private IXLStyle style; + public IXLStyle Style + { + get + { + return style; + } + set + { + style = new XLStyle(null, value); + } + } + + public IEnumerable Styles + { + get + { + UpdatingStyle = true; + yield return style; + UpdatingStyle = false; + } + } + + public Boolean UpdatingStyle { get; set; } + + #endregion + + + public XLCellValues DataType { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLColumn.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLColumn.cs new file mode 100644 index 0000000..33092d2 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLColumn.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel.Style; + +namespace ClosedXML.Excel +{ + public class XLColumn: IXLColumn + { + public XLColumn(Int32 column, Dictionary cellsCollection, IXLStyle defaultStyle) + { + FirstCellAddress = new XLAddress(1, column); + LastCellAddress = new XLAddress(XLWorksheet.MaxNumberOfRows, column); + CellsCollection = cellsCollection; + } + + public Int32 Width { get; set; } + + #region IXLRange Members + + public Dictionary CellsCollection { get; private set; } + public IXLAddress FirstCellAddress { get; private set; } + public IXLAddress LastCellAddress { get; private set; } + + #endregion + + #region IXLStylized Members + + private IXLStyle style; + public IXLStyle Style + { + get + { + return style; + } + set + { + style = new XLStyle(this, value); + } + } + + public IEnumerable Styles + { + get + { + UpdatingStyle = true; + yield return style; + foreach (var c in CellsCollection.Values.Where(c => c.Address.Column == FirstCellAddress.Column)) + { + yield return c.Style; + } + UpdatingStyle = false; + } + } + + public Boolean UpdatingStyle { get; set; } + + #endregion + + #region IXLRange Members + + public IXLRange Row(int row) + { + var address = new XLAddress(row, FirstCellAddress.Column); + return this.Range(address, address); + } + + public IXLRange Column(int column) + { + return this; + } + + public IXLRange Column(string column) + { + return this; + } + + #endregion + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLRange.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLRange.cs new file mode 100644 index 0000000..256561b --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLRange.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel.Style; + +namespace ClosedXML.Excel +{ + public class XLRange: IXLRange + { + private IXLStyle defaultStyle; + public XLRange(IXLAddress firstCellAddress, IXLAddress lastCellAddress, Dictionary cellCollection) + { + FirstCellAddress = firstCellAddress; + LastCellAddress = lastCellAddress; + CellsCollection = cellCollection; + this.defaultStyle = new XLStyle(this, this.FirstCell().Style); + } + + #region IXLRange Members + + public Dictionary CellsCollection { get; private set; } + + public IXLAddress FirstCellAddress { get; private set; } + + public IXLAddress LastCellAddress { get; private set; } + + public IXLRange Row(Int32 row) + { + IXLAddress firstCellAddress = new XLAddress(row, 1); + IXLAddress lastCellAddress = new XLAddress(row, this.ColumnCount()); + return this.Range(firstCellAddress, lastCellAddress); + } + public IXLRange Column(Int32 column) + { + IXLAddress firstCellAddress = new XLAddress(1, column); + IXLAddress lastCellAddress = new XLAddress(this.RowCount(), column); + return this.Range(firstCellAddress, lastCellAddress); + } + public IXLRange Column(String column) + { + IXLAddress firstCellAddress = new XLAddress(1, column); + IXLAddress lastCellAddress = new XLAddress(this.RowCount(), column); + return this.Range(firstCellAddress, lastCellAddress); + } + + + #endregion + + #region IXLStylized Members + + public IXLStyle Style + { + get + { + return this.defaultStyle; + } + set + { + this.Cells().ForEach(c => c.Style = value); + } + } + + public IEnumerable Styles + { + get + { + UpdatingStyle = true; + foreach (var cell in this.Cells()) + { + yield return cell.Style; + } + UpdatingStyle = false; + } + } + + public Boolean UpdatingStyle { get; set; } + + #endregion + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLRow.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLRow.cs new file mode 100644 index 0000000..4433232 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLRow.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel.Style; + +namespace ClosedXML.Excel +{ + public class XLRow: IXLRange + { + public XLRow(Int32 row, Dictionary cellsCollection, IXLStyle defaultStyle) + { + FirstCellAddress = new XLAddress(row, 1); + LastCellAddress = new XLAddress(row, XLWorksheet.MaxNumberOfColumns); + CellsCollection = cellsCollection; + + var defaultAddress = new XLAddress(row, 0); + if (!cellsCollection.ContainsKey(defaultAddress)) + { + DefaultCell = new XLCell(defaultAddress, defaultStyle); + cellsCollection.Add(defaultAddress, DefaultCell); + } + else + { + DefaultCell = cellsCollection[defaultAddress]; + } + } + + private IXLCell DefaultCell { get; set; } + + #region IXLRange Members + + public Dictionary CellsCollection { get; private set; } + public IXLAddress FirstCellAddress { get; private set; } + public IXLAddress LastCellAddress { get; private set; } + + #endregion + + #region IXLStylized Members + + public IXLStyle Style + { + get + { + return DefaultCell.Style; + } + set + { + DefaultCell.Style = value; + } + } + + public IEnumerable Styles + { + get + { + UpdatingStyle = true; + foreach (var c in CellsCollection.Values.Where(c => c.Address.Row == FirstCellAddress.Row)) + { + yield return c.Style; + } + UpdatingStyle = false; + } + } + + public Boolean UpdatingStyle { get; set; } + + #endregion + + + #region IXLRange Members + + public IXLRange Row(int row) + { + return this; + } + + public IXLRange Column(int column) + { + var address = new XLAddress(FirstCellAddress.Row, column); + return this.Range(address, address); + } + + public IXLRange Column(string column) + { + var address = new XLAddress(FirstCellAddress.Row, column); + return this.Range(address, address); + } + + #endregion + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook.cs new file mode 100644 index 0000000..b08d49a --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel.Style; +using System.IO; +using System.Drawing; + +namespace ClosedXML.Excel +{ + public partial class XLWorkbook: IXLWorkbook + { + public XLWorkbook() + { + Worksheets = new XLWorksheets(); + } + #region IXLWorkbook Members + + public IXLWorksheets Worksheets { get; private set; } + + /// + /// Gets the file name of the workbook. + /// + public String Name { get; private set; } + + /// + /// Gets the file name of the workbook including its full directory. + /// + public String FullName { get; private set; } + + public void SaveAs(String file, Boolean overwrite = false) + { + if (overwrite && File.Exists(file)) File.Delete(file); + + // For maintainability reasons the XLWorkbook class was divided into two files. + // The method CreatePackage can be located in the file XLWorkbook_Save.cs + CreatePackage(file); + } + + #endregion + + #region Static + + private static XLStyle defaultStyle; + /// + /// Gets the default style for new workbooks. + /// + public static XLStyle DefaultStyle + { + get + { + if (defaultStyle == null) + { + defaultStyle = new XLStyle(null, null) + { + Font = new XLFont(null, null) + { + Bold = false, + Italic = false, + Underline = XLFontUnderlineValues.None, + Strikethrough = false, + VerticalAlignment = XLFontVerticalTextAlignmentValues.Baseline, + FontSize = 11, + FontColor = Color.FromArgb(0,0,0), + FontName = "Calibri", + FontFamilyNumbering = XLFontFamilyNumberingValues.Swiss + } + , Alignment = new XLAlignment(), Border = new XLBorder(), NumberFormat = new XLNumberFormat(), + Fill = new XLFill(null) + { + BackgroundColor = Color.FromArgb(255,255,255), + PatternType = XLFillPatternValues.None, + PatternColor = Color.FromArgb(255, 255, 255) + } + //Border = new XLBorder(null) + // { + // BottomBorder = BorderStyleValues.None, + // DiagonalBorder = BorderStyleValues.None, + // DiagonalDown = false, + // DiagonalUp = false, + // LeftBorder = BorderStyleValues.None, + // RightBorder = BorderStyleValues.None, + // TopBorder = BorderStyleValues.None, + // BottomBorderColor = "000000", + // DiagonalBorderColor = "000000", + // LeftBorderColor = "000000", + // RightBorderColor = "000000", + // TopBorderColor = "000000" + // }, + //NumberFormat = new XLNumberFormat(0), + //Alignment = new XLAlignment(null) + // { + // Horizontal = HorizontalAlignmentValues.General, + // Indent = 0, + // JustifyLastLine = false, + // ReadingOrder = OPReadingOrders.ContextDependent, + // RelativeIndent = 0, + // ShrinkToFit = false, + // TextRotation = 0, + // Vertical = VerticalAlignmentValues.Bottom, + // WrapText = false + // } + }; + } + return defaultStyle; + } + } + + #endregion + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs new file mode 100644 index 0000000..8fbee37 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs @@ -0,0 +1,1278 @@ +using DocumentFormat.OpenXml.Packaging; +using Ap = DocumentFormat.OpenXml.ExtendedProperties; +using Vt = DocumentFormat.OpenXml.VariantTypes; +using DocumentFormat.OpenXml; +using DocumentFormat.OpenXml.Spreadsheet; +using A = DocumentFormat.OpenXml.Drawing; +using Xdr = DocumentFormat.OpenXml.Drawing.Spreadsheet; +using C = DocumentFormat.OpenXml.Drawing.Charts; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using ClosedXML.Excel.Style; + + +namespace ClosedXML.Excel +{ + public partial class XLWorkbook + { + + private Dictionary sharedStrings = new Dictionary(); + private struct FontInfo { public UInt32 FontId; public IXLFont Font; }; + private struct FillInfo { public UInt32 FillId; public IXLFill Fill; }; + private struct BorderInfo { public UInt32 BorderId; public IXLBorder Border; }; + private struct NumberFormatInfo { public UInt32 NumberFormatId; public IXLNumberFormat NumberFormat; }; + + + private struct StyleInfo + { + public UInt32 StyleId; + public UInt32 FontId; + public UInt32 FillId; + public UInt32 BorderId; + public UInt32 NumberFormatId; + public IXLStyle Style; + }; + + private Dictionary sharedStyles = new Dictionary(); + + private CellValues GetCellValue(XLCellValues xlCellValue) + { + switch (xlCellValue) + { + case XLCellValues.Boolean: return CellValues.Boolean; + case XLCellValues.DateTime: return CellValues.Date; + case XLCellValues.Number: return CellValues.Number; + case XLCellValues.SharedString: return CellValues.SharedString; + default: throw new NotImplementedException(); + } + } + + private UnderlineValues GetUnderlineValue(XLFontUnderlineValues xlFontUnderlineValue) + { + switch (xlFontUnderlineValue) + { + case XLFontUnderlineValues.Double: return UnderlineValues.Double; + case XLFontUnderlineValues.DoubleAccounting: return UnderlineValues.DoubleAccounting; + case XLFontUnderlineValues.None: return UnderlineValues.None; + case XLFontUnderlineValues.Single: return UnderlineValues.Single; + case XLFontUnderlineValues.SingleAccounting: return UnderlineValues.SingleAccounting; + default: throw new NotImplementedException(); + } + } + + private VerticalAlignmentRunValues GetVerticalAlignmentRunValue(XLFontVerticalTextAlignmentValues xlFontVerticalTextAlignmentValue) + { + switch (xlFontVerticalTextAlignmentValue) + { + case XLFontVerticalTextAlignmentValues.Baseline: return VerticalAlignmentRunValues.Baseline; + case XLFontVerticalTextAlignmentValues.Subscript: return VerticalAlignmentRunValues.Subscript; + case XLFontVerticalTextAlignmentValues.Superscript: return VerticalAlignmentRunValues.Superscript; + default: throw new NotImplementedException(); + } + } + + private PatternValues GetPatternValue(XLFillPatternValues xlFillPatternValue) + { + switch (xlFillPatternValue) + { + case XLFillPatternValues.DarkDown: return PatternValues.DarkDown; + case XLFillPatternValues.DarkGray: return PatternValues.DarkGray; + case XLFillPatternValues.DarkGrid: return PatternValues.DarkGrid; + case XLFillPatternValues.DarkHorizontal: return PatternValues.DarkHorizontal; + case XLFillPatternValues.DarkTrellis: return PatternValues.DarkTrellis; + case XLFillPatternValues.DarkUp: return PatternValues.DarkUp; + case XLFillPatternValues.DarkVertical: return PatternValues.DarkVertical; + case XLFillPatternValues.Gray0625: return PatternValues.Gray0625; + case XLFillPatternValues.Gray125: return PatternValues.Gray125; + case XLFillPatternValues.LightDown: return PatternValues.LightDown; + case XLFillPatternValues.LightGray: return PatternValues.LightGray; + case XLFillPatternValues.LightGrid: return PatternValues.LightGrid; + case XLFillPatternValues.LightHorizontal: return PatternValues.LightHorizontal; + case XLFillPatternValues.LightTrellis: return PatternValues.LightTrellis; + case XLFillPatternValues.LightUp: return PatternValues.LightUp; + case XLFillPatternValues.LightVertical: return PatternValues.LightVertical; + case XLFillPatternValues.MediumGray: return PatternValues.MediumGray; + case XLFillPatternValues.None: return PatternValues.None; + case XLFillPatternValues.Solid: return PatternValues.Solid; + default: throw new NotImplementedException(); + } + } + + private BorderStyleValues GetBorderStyleValue(XLBorderStyleValues xlBorderStyleValue) + { + switch (xlBorderStyleValue) + { + case XLBorderStyleValues.DashDot: return BorderStyleValues.DashDot; + case XLBorderStyleValues.DashDotDot: return BorderStyleValues.DashDotDot; + case XLBorderStyleValues.Dashed: return BorderStyleValues.Dashed; + case XLBorderStyleValues.Dotted: return BorderStyleValues.Dotted; + case XLBorderStyleValues.Double: return BorderStyleValues.Double; + case XLBorderStyleValues.Hair: return BorderStyleValues.Hair; + case XLBorderStyleValues.Medium: return BorderStyleValues.Medium; + case XLBorderStyleValues.MediumDashDot: return BorderStyleValues.MediumDashDot; + case XLBorderStyleValues.MediumDashDotDot: return BorderStyleValues.MediumDashDotDot; + case XLBorderStyleValues.MediumDashed: return BorderStyleValues.MediumDashed; + case XLBorderStyleValues.None: return BorderStyleValues.None; + case XLBorderStyleValues.SlantDashDot: return BorderStyleValues.SlantDashDot; + case XLBorderStyleValues.Thick: return BorderStyleValues.Thick; + case XLBorderStyleValues.Thin: return BorderStyleValues.Thin; + default: throw new NotImplementedException(); + } + } + + private HorizontalAlignmentValues GetHorizontalAlignmentValue(XLAlignmentHorizontalValues xlAlignmentHorizontalValue) + { + switch (xlAlignmentHorizontalValue) + { + case XLAlignmentHorizontalValues.Center: return HorizontalAlignmentValues.Center; + case XLAlignmentHorizontalValues.CenterContinuous: return HorizontalAlignmentValues.CenterContinuous; + case XLAlignmentHorizontalValues.Distributed: return HorizontalAlignmentValues.Distributed; + case XLAlignmentHorizontalValues.Fill: return HorizontalAlignmentValues.Fill; + case XLAlignmentHorizontalValues.General: return HorizontalAlignmentValues.General; + case XLAlignmentHorizontalValues.Justify: return HorizontalAlignmentValues.Justify; + case XLAlignmentHorizontalValues.Left: return HorizontalAlignmentValues.Left; + case XLAlignmentHorizontalValues.Right: return HorizontalAlignmentValues.Right; + default: throw new NotImplementedException(); + } + } + + private VerticalAlignmentValues GetVerticalAlignmentValue(XLAlignmentVerticalValues xlAlignmentVerticalValue) + { + switch (xlAlignmentVerticalValue) + { + case XLAlignmentVerticalValues.Bottom: return VerticalAlignmentValues.Bottom; + case XLAlignmentVerticalValues.Center: return VerticalAlignmentValues.Center; + case XLAlignmentVerticalValues.Distributed: return VerticalAlignmentValues.Distributed; + case XLAlignmentVerticalValues.Justify: return VerticalAlignmentValues.Justify; + case XLAlignmentVerticalValues.Top: return VerticalAlignmentValues.Top; + default: throw new NotImplementedException(); + } + } + + // Creates a SpreadsheetDocument. + private void CreatePackage(String filePath) + { + using (SpreadsheetDocument package = SpreadsheetDocument.Create(filePath, SpreadsheetDocumentType.Workbook)) + { + CreateParts(package); + } + } + + // Adds child parts and generates content of the specified part. + private void CreateParts(SpreadsheetDocument document) + { + ExtendedFilePropertiesPart extendedFilePropertiesPart1 = document.AddNewPart("rId3"); + GenerateExtendedFilePropertiesPartContent(extendedFilePropertiesPart1); + + WorkbookPart workbookPart = document.AddWorkbookPart(); + GenerateWorkbookPartContent(workbookPart); + + SharedStringTablePart sharedStringTablePart = workbookPart.AddNewPart("rId6"); + GenerateSharedStringTablePartContent(sharedStringTablePart); + + WorkbookStylesPart workbookStylesPart = workbookPart.AddNewPart("rId5"); + GenerateWorkbookStylesPartContent(workbookStylesPart); + + UInt32 sheetId = 0; + foreach (var worksheet in Worksheets) + { + sheetId++; + WorksheetPart worksheetPart = workbookPart.AddNewPart("rId" + sheetId.ToString()); + GenerateWorksheetPartContent(worksheetPart, worksheet); + } + + ThemePart themePart1 = workbookPart.AddNewPart("rId4"); + GenerateThemePartContent(themePart1); + + //SetPackageProperties(document); + } + + private void GenerateExtendedFilePropertiesPartContent(ExtendedFilePropertiesPart extendedFilePropertiesPart) + { + Ap.Properties properties1 = new Ap.Properties(); + properties1.AddNamespaceDeclaration("vt", "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"); + Ap.Application application1 = new Ap.Application(); + application1.Text = "Microsoft Excel"; + Ap.DocumentSecurity documentSecurity1 = new Ap.DocumentSecurity(); + documentSecurity1.Text = "0"; + Ap.ScaleCrop scaleCrop1 = new Ap.ScaleCrop(); + scaleCrop1.Text = "false"; + + Ap.HeadingPairs headingPairs1 = new Ap.HeadingPairs(); + + Vt.VTVector vTVector1 = new Vt.VTVector() { BaseType = Vt.VectorBaseValues.Variant, Size = (UInt32Value)2U }; + + Vt.Variant variant1 = new Vt.Variant(); + Vt.VTLPSTR vTLPSTR1 = new Vt.VTLPSTR(); + vTLPSTR1.Text = "Worksheets"; + + variant1.Append(vTLPSTR1); + + Vt.Variant variant2 = new Vt.Variant(); + Vt.VTInt32 vTInt321 = new Vt.VTInt32(); + vTInt321.Text = "3"; + + variant2.Append(vTInt321); + + vTVector1.Append(variant1); + vTVector1.Append(variant2); + + headingPairs1.Append(vTVector1); + + Ap.TitlesOfParts titlesOfParts1 = new Ap.TitlesOfParts(); + + UInt32 sheetCount = (UInt32)Worksheets.Count(); + Vt.VTVector vTVector2 = new Vt.VTVector() { BaseType = Vt.VectorBaseValues.Lpstr, Size = (UInt32Value)sheetCount }; + foreach (var worksheet in Worksheets) + { + Vt.VTLPSTR vTLPSTR2 = new Vt.VTLPSTR(); + vTLPSTR2.Text = worksheet.Name; + vTVector2.Append(vTLPSTR2); + } + + titlesOfParts1.Append(vTVector2); + Ap.Company company1 = new Ap.Company(); + company1.Text = "NSI"; + Ap.LinksUpToDate linksUpToDate1 = new Ap.LinksUpToDate(); + linksUpToDate1.Text = "false"; + Ap.SharedDocument sharedDocument1 = new Ap.SharedDocument(); + sharedDocument1.Text = "false"; + Ap.HyperlinksChanged hyperlinksChanged1 = new Ap.HyperlinksChanged(); + hyperlinksChanged1.Text = "false"; + Ap.ApplicationVersion applicationVersion1 = new Ap.ApplicationVersion(); + applicationVersion1.Text = "12.0000"; + + properties1.Append(application1); + properties1.Append(documentSecurity1); + properties1.Append(scaleCrop1); + properties1.Append(headingPairs1); + properties1.Append(titlesOfParts1); + properties1.Append(company1); + properties1.Append(linksUpToDate1); + properties1.Append(sharedDocument1); + properties1.Append(hyperlinksChanged1); + properties1.Append(applicationVersion1); + + extendedFilePropertiesPart.Properties = properties1; + } + + private void GenerateWorkbookPartContent(WorkbookPart workbookPart) + { + Workbook workbook1 = new Workbook(); + workbook1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); + FileVersion fileVersion1 = new FileVersion() { ApplicationName = "xl", LastEdited = "4", LowestEdited = "4", BuildVersion = "4506" }; + WorkbookProperties workbookProperties1 = new WorkbookProperties() { CodeName = "ThisWorkbook", DefaultThemeVersion = (UInt32Value)124226U }; + + BookViews bookViews1 = new BookViews(); + WorkbookView workbookView1 = new WorkbookView() { XWindow = 0, YWindow = 30, WindowWidth = (UInt32Value)14160U, WindowHeight = (UInt32Value)11580U }; + + bookViews1.Append(workbookView1); + + UInt32 sheetId = 0; + Sheets sheets = new Sheets(); + foreach (var worksheet in Worksheets) + { + sheetId++; + Sheet sheet = new Sheet() { Name = worksheet.Name, SheetId = (UInt32Value)sheetId, Id = "rId" + sheetId.ToString() }; + sheets.Append(sheet); + } + + CalculationProperties calculationProperties1 = new CalculationProperties() { CalculationId = (UInt32Value)125725U, CalculationMode = CalculateModeValues.Manual }; + + workbook1.Append(fileVersion1); + workbook1.Append(workbookProperties1); + workbook1.Append(bookViews1); + workbook1.Append(sheets); + workbook1.Append(calculationProperties1); + + workbookPart.Workbook = workbook1; + } + + private void GenerateSharedStringTablePartContent(SharedStringTablePart sharedStringTablePart) + { + List combined = new List(); + Worksheets.ForEach(w => combined.AddRange(w.CellsCollection.Values.Where(c => c.DataType == XLCellValues.SharedString && c.Value != null).Select(c => c.Value).Distinct())); + var distinctStrings = combined.Distinct(); + UInt32 stringCount = (UInt32)distinctStrings.Count(); + SharedStringTable sharedStringTable = new SharedStringTable() { Count = (UInt32Value)stringCount, UniqueCount = (UInt32Value)stringCount }; + + UInt32 stringId = 0; + foreach (var s in distinctStrings) + { + sharedStrings.Add(s, stringId++); + + SharedStringItem sharedStringItem = new SharedStringItem(); + Text text = new Text(); + text.Text = s; + sharedStringItem.Append(text); + sharedStringTable.Append(sharedStringItem); + } + + sharedStringTablePart.SharedStringTable = sharedStringTable; + } + + private void GenerateWorkbookStylesPartContent(WorkbookStylesPart workbookStylesPart) + { + var defaultStyle = XLWorkbook.DefaultStyle; + Dictionary sharedFonts = new Dictionary(); + sharedFonts.Add(defaultStyle.Font.ToString(), new FontInfo() { FontId = 0, Font = defaultStyle.Font }); + + Dictionary sharedFills = new Dictionary(); + sharedFills.Add(defaultStyle.Fill.ToString(), new FillInfo() { FillId = 2, Fill = defaultStyle.Fill }); + + Dictionary sharedBorders = new Dictionary(); + sharedBorders.Add(defaultStyle.Border.ToString(), new BorderInfo() { BorderId = 0, Border = defaultStyle.Border }); + + Dictionary sharedNumberFormats = new Dictionary(); + sharedNumberFormats.Add(defaultStyle.NumberFormat.ToString(), new NumberFormatInfo() { NumberFormatId = 0, NumberFormat = defaultStyle.NumberFormat }); + + //Dictionary sharedAlignments = new Dictionary(); + //sharedAlignments.Add(defaultStyle.Alignment.ToString(), new AlignmentInfo() { AlignmentId = 0, Alignment = defaultStyle.Alignment }); + + sharedStyles.Add(defaultStyle.ToString(), + new StyleInfo() + { + StyleId = 0, + Style = defaultStyle, + FontId = 0, + FillId = 0, + BorderId = 0, + NumberFormatId = 0 + //AlignmentId = 0 + }); + + UInt32 styleCount = 1; + UInt32 fontCount = 1; + UInt32 fillCount = 3; + UInt32 borderCount = 1; + UInt32 numberFormatCount = 1; + + foreach (var worksheet in Worksheets) + { + foreach (var cell in worksheet.CellsCollection.Values) + { + if (!sharedFonts.ContainsKey(cell.Style.Font.ToString())) + { + sharedFonts.Add(cell.Style.Font.ToString(), new FontInfo() { FontId = fontCount++, Font = cell.Style.Font }); + } + + if (!sharedFills.ContainsKey(cell.Style.Fill.ToString())) + { + sharedFills.Add(cell.Style.Fill.ToString(), new FillInfo() { FillId = fillCount++, Fill = cell.Style.Fill }); + } + + if (!sharedBorders.ContainsKey(cell.Style.Border.ToString())) + { + sharedBorders.Add(cell.Style.Border.ToString(), new BorderInfo() { BorderId = borderCount++, Border = cell.Style.Border }); + } + + if (!cell.Style.NumberFormat.NumberFormatId.HasValue && !sharedNumberFormats.ContainsKey(cell.Style.NumberFormat.ToString())) + { + sharedNumberFormats.Add(cell.Style.NumberFormat.ToString(), new NumberFormatInfo() { NumberFormatId = numberFormatCount + 164, NumberFormat = cell.Style.NumberFormat }); + //cell.Style.NumberFormat = new OPNumberFormat(numberFormatCount); + numberFormatCount++; + } + //else if (!cell.Style.NumberFormat.NumberFormatId.HasValue) + //{ + // cell.Style.NumberFormat = new OPNumberFormat(sharedNumberFormats[cell.Style.NumberFormat.ToString()].NumberFormatId); + //} + + if (!sharedStyles.ContainsKey(cell.Style.ToString())) + { + UInt32 numberFormatId; + if (cell.Style.NumberFormat.NumberFormatId.HasValue) + numberFormatId = cell.Style.NumberFormat.NumberFormatId.Value; + else + numberFormatId = sharedNumberFormats[cell.Style.NumberFormat.ToString()].NumberFormatId; + + sharedStyles.Add(cell.Style.ToString(), + new StyleInfo() + { + StyleId = styleCount++, + Style = cell.Style, + FontId = sharedFonts[cell.Style.Font.ToString()].FontId, + FillId = sharedFills[cell.Style.Fill.ToString()].FillId, + BorderId = sharedBorders[cell.Style.Border.ToString()].BorderId, + NumberFormatId = numberFormatId + }); + } + } + } + + Stylesheet stylesheet1 = new Stylesheet(); + + NumberingFormats numberingFormats = new NumberingFormats() { Count = (UInt32Value)numberFormatCount }; + foreach (var numberFormatInfo in sharedNumberFormats.Values) + { + NumberingFormat numberingFormat = new NumberingFormat() { NumberFormatId = (UInt32Value)numberFormatInfo.NumberFormatId, FormatCode = numberFormatInfo.NumberFormat.Format }; + numberingFormats.Append(numberingFormat); + } + + Fonts fonts = new Fonts() { Count = (UInt32Value)fontCount }; + + foreach (var fontInfo in sharedFonts.Values) + { + Bold bold = fontInfo.Font.Bold ? new Bold() : null; + Italic italic = fontInfo.Font.Italic ? new Italic() : null; + Underline underline = fontInfo.Font.Underline != XLFontUnderlineValues.None ? new Underline() { Val = GetUnderlineValue(fontInfo.Font.Underline) } : null; + Strike strike = fontInfo.Font.Strikethrough ? new Strike() : null; + VerticalTextAlignment verticalAlignment = new VerticalTextAlignment() { Val = GetVerticalAlignmentRunValue(fontInfo.Font.VerticalAlignment) }; + Shadow shadow = fontInfo.Font.Shadow ? new Shadow() : null; + Font font = new Font(); + FontSize fontSize = new FontSize() { Val = fontInfo.Font.FontSize }; + Color color = new Color() { Rgb = fontInfo.Font.FontColor.ToHex() }; + FontName fontName = new FontName() { Val = fontInfo.Font.FontName }; + FontFamilyNumbering fontFamilyNumbering = new FontFamilyNumbering() { Val = (Int32)fontInfo.Font.FontFamilyNumbering }; + //FontScheme fontScheme = new FontScheme() { Val = FontSchemeValues.Minor }; + + if (bold != null) font.Append(bold); + if (italic != null) font.Append(italic); + if (underline != null) font.Append(underline); + if (strike != null) font.Append(strike); + font.Append(verticalAlignment); + if (shadow != null) font.Append(shadow); + font.Append(fontSize); + font.Append(color); + font.Append(fontName); + font.Append(fontFamilyNumbering); + //font.Append(fontScheme); + + fonts.Append(font); + } + + Fills fills = new Fills() { Count = (UInt32Value)fillCount }; + + Fill fill1 = new Fill(); + PatternFill patternFill1 = new PatternFill() { PatternType = PatternValues.None }; + fill1.Append(patternFill1); + fills.Append(fill1); + + Fill fill2 = new Fill(); + PatternFill patternFill2 = new PatternFill() { PatternType = PatternValues.Gray125 }; + fill2.Append(patternFill2); + fills.Append(fill2); + + foreach (var fillInfo in sharedFills.Values) + { + Fill fill = new Fill(); + PatternFill patternFill = new PatternFill() { PatternType = GetPatternValue(fillInfo.Fill.PatternType) }; + ForegroundColor foregroundColor = new ForegroundColor() { Rgb = fillInfo.Fill.PatternColor.ToHex() }; + BackgroundColor backgroundColor = new BackgroundColor() { Rgb = fillInfo.Fill.PatternBackgroundColor.ToHex() }; + + patternFill.Append(foregroundColor); + patternFill.Append(backgroundColor); + + fill.Append(patternFill); + fills.Append(fill); + } + + Borders borders = new Borders() { Count = (UInt32Value)borderCount }; + + foreach (var borderInfo in sharedBorders.Values) + { + Border border = new Border() { DiagonalUp = borderInfo.Border.DiagonalUp, DiagonalDown = borderInfo.Border.DiagonalDown }; + + LeftBorder leftBorder = new LeftBorder() { Style = GetBorderStyleValue(borderInfo.Border.LeftBorder) }; + Color leftBorderColor = new Color() { Rgb = borderInfo.Border.LeftBorderColor.ToHex() }; + leftBorder.Append(leftBorderColor); + border.Append(leftBorder); + + RightBorder rightBorder = new RightBorder() { Style = GetBorderStyleValue(borderInfo.Border.RightBorder) }; + Color rightBorderColor = new Color() { Rgb = borderInfo.Border.RightBorderColor.ToHex() }; + rightBorder.Append(rightBorderColor); + border.Append(rightBorder); + + TopBorder topBorder = new TopBorder() { Style = GetBorderStyleValue(borderInfo.Border.TopBorder) }; + Color topBorderColor = new Color() { Rgb = borderInfo.Border.TopBorderColor.ToHex() }; + topBorder.Append(topBorderColor); + border.Append(topBorder); + + BottomBorder bottomBorder = new BottomBorder() { Style = GetBorderStyleValue(borderInfo.Border.BottomBorder) }; + Color bottomBorderColor = new Color() { Rgb = borderInfo.Border.BottomBorderColor.ToHex() }; + bottomBorder.Append(bottomBorderColor); + border.Append(bottomBorder); + + DiagonalBorder diagonalBorder = new DiagonalBorder() { Style = GetBorderStyleValue(borderInfo.Border.DiagonalBorder) }; + Color diagonalBorderColor = new Color() { Rgb = borderInfo.Border.DiagonalBorderColor.ToHex() }; + diagonalBorder.Append(diagonalBorderColor); + border.Append(diagonalBorder); + + borders.Append(border); + } + + + + // Cell style formats = Formats to be used by the cells and named styles + CellStyleFormats cellStyleFormats = new CellStyleFormats() { Count = (UInt32Value)styleCount }; + // Cell formats = Any kind of formatting applied to a cell + CellFormats cellFormats = new CellFormats() { Count = (UInt32Value)styleCount }; + foreach (var styleInfo in sharedStyles.Values) + { + var formatId = styleInfo.StyleId; + var numberFormatId = styleInfo.NumberFormatId; + var fontId = styleInfo.FontId; + var fillId = styleInfo.FillId; + var borderId = styleInfo.BorderId; + Boolean applyFill = GetPatternValue(styleInfo.Style.Fill.PatternType) == PatternValues.None; + IXLBorder opBorder = styleInfo.Style.Border; + Boolean applyBorder = ( + GetBorderStyleValue(opBorder.BottomBorder) != BorderStyleValues.None + || GetBorderStyleValue(opBorder.DiagonalBorder) != BorderStyleValues.None + || GetBorderStyleValue(opBorder.RightBorder) != BorderStyleValues.None + || GetBorderStyleValue(opBorder.LeftBorder) != BorderStyleValues.None + || GetBorderStyleValue(opBorder.TopBorder) != BorderStyleValues.None); + + CellFormat cellStyleFormat = new CellFormat() { NumberFormatId = (UInt32Value)numberFormatId, FontId = (UInt32Value)fontId, FillId = (UInt32Value)fillId, BorderId = (UInt32Value)borderId, ApplyNumberFormat = false, ApplyFill = applyFill, ApplyBorder = applyBorder, ApplyAlignment = false, ApplyProtection = false }; + cellStyleFormats.Append(cellStyleFormat); + + CellFormat cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)numberFormatId, FontId = (UInt32Value)fontId, FillId = (UInt32Value)fillId, BorderId = (UInt32Value)borderId, FormatId = (UInt32Value)formatId, ApplyNumberFormat = false, ApplyFill = applyFill, ApplyBorder = applyBorder, ApplyAlignment = false, ApplyProtection = false }; + Alignment alignment = new Alignment() + { + Horizontal = GetHorizontalAlignmentValue(styleInfo.Style.Alignment.Horizontal), + Vertical = GetVerticalAlignmentValue(styleInfo.Style.Alignment.Vertical), + Indent = styleInfo.Style.Alignment.Indent, + ReadingOrder = (UInt32)styleInfo.Style.Alignment.ReadingOrder, + WrapText = styleInfo.Style.Alignment.WrapText, + TextRotation = styleInfo.Style.Alignment.TextRotation, + ShrinkToFit = styleInfo.Style.Alignment.ShrinkToFit, + RelativeIndent = styleInfo.Style.Alignment.RelativeIndent, + JustifyLastLine = styleInfo.Style.Alignment.JustifyLastLine + }; + cellFormat.Append(alignment); + + cellFormats.Append(cellFormat); + } + + + + // Cell styles = Named styles + CellStyles cellStyles1 = new CellStyles() { Count = (UInt32Value)1U }; + var defaultFormatId = sharedStyles.Values.Where(s => s.Style.ToString() == XLWorkbook.DefaultStyle.ToString()).Single().StyleId; + CellStyle cellStyle1 = new CellStyle() { Name = "Normal", FormatId = (UInt32Value)defaultFormatId, BuiltinId = (UInt32Value)0U }; + cellStyles1.Append(cellStyle1); + + DifferentialFormats differentialFormats1 = new DifferentialFormats() { Count = (UInt32Value)0U }; + TableStyles tableStyles1 = new TableStyles() { Count = (UInt32Value)0U, DefaultTableStyle = "TableStyleMedium9", DefaultPivotStyle = "PivotStyleLight16" }; + + stylesheet1.Append(numberingFormats); + stylesheet1.Append(fonts); + stylesheet1.Append(fills); + stylesheet1.Append(borders); + stylesheet1.Append(cellStyleFormats); + stylesheet1.Append(cellFormats); + stylesheet1.Append(cellStyles1); + stylesheet1.Append(differentialFormats1); + stylesheet1.Append(tableStyles1); + + workbookStylesPart.Stylesheet = stylesheet1; + } + + private void GenerateWorksheetPartContent(WorksheetPart worksheetPart, IXLWorksheet xlWorksheet) + { + Worksheet worksheet = new Worksheet(); + worksheet.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); + SheetProperties sheetProperties = new SheetProperties() { CodeName = xlWorksheet.Name.RemoveSpecialCharacters() }; + + UInt32 maxColumn = 0; + UInt32 maxRow = 0; + + String sheetDimensionReference = "A1"; + if (xlWorksheet.CellsCollection.Count > 0) + { + maxColumn = (UInt32)xlWorksheet.CellsCollection.Select(c => c.Key.Column).Max(); + maxRow = (UInt32)xlWorksheet.CellsCollection.Select(c => c.Key.Row).Max(); + sheetDimensionReference = "A1:" + new XLAddress((Int32)maxRow, (Int32)maxColumn).ToString(); + } + + SheetDimension sheetDimension = new SheetDimension() { Reference = sheetDimensionReference }; + + Boolean tabSelected = xlWorksheet.Name == Worksheets.GetWorksheet(0).Name; + + SheetViews sheetViews = new SheetViews(); + SheetView sheetView = new SheetView() { TabSelected = tabSelected, WorkbookViewId = (UInt32Value)0U }; + + sheetViews.Append(sheetView); + SheetFormatProperties sheetFormatProperties3 = new SheetFormatProperties() { DefaultRowHeight = 15D }; + + Columns columns = null; + //if (xlWorksheet.Columns.Count > 0) + //{ + // columns = new Columns(); + // foreach (var opColumn in xlWorksheet.Columns.Values) + // { + // Column column = new Column() + // { + // Min = (UInt32Value)opColumn.Column, + // Max = (UInt32Value)opColumn.Column, + // Width = opColumn.Width, + // CustomWidth = true + // }; + // columns.Append(column); + // } + //} + + SheetData sheetData = new SheetData(); + + var distinctRows = xlWorksheet.CellsCollection.Where(c => c.Key.Column > 0 && c.Key.Row > 0).Select(c => c.Key.Row).Distinct(); + foreach (var distinctRow in distinctRows.OrderBy(r => r)) + { + Row row = new Row() { RowIndex = (UInt32Value)(UInt32)distinctRow, Spans = new ListValue() { InnerText = "1:" + maxColumn.ToString() } }; + //if (xlWorksheet.Rows.ContainsKey(distinctRow)) + //{ + // row.Height = xlWorksheet.Rows[distinctRow].Height; + // row.CustomHeight = true; + //} + foreach (var opCell in xlWorksheet.CellsCollection + .Where(c => c.Key.Row == distinctRow && c.Key.Column != 0) + .OrderBy(c => c.Key) + .Select(c => c)) + { + var styleId = sharedStyles[opCell.Value.Style.ToString()].StyleId; + Cell cell; + var dataType = opCell.Value.DataType; + var cellReference = opCell.Key.ToString(); + if (opCell.Value.DataType == XLCellValues.DateTime) + { + cell = new Cell() + { + CellReference = cellReference, + StyleIndex = styleId + }; + } + else if (styleId == 0) + { + cell = new Cell() + { + CellReference = cellReference, + DataType = GetCellValue(dataType) + }; + } + else + { + cell = new Cell() + { + CellReference = cellReference, + DataType = GetCellValue(dataType), + StyleIndex = styleId + }; + } + CellValue cellValue = new CellValue(); + if (dataType == XLCellValues.SharedString) + { + cellValue.Text = sharedStrings[opCell.Value.Value].ToString(); + } + else + { + cellValue.Text = opCell.Value.Value; + } + + cell.Append(cellValue); + row.Append(cell); + } + sheetData.Append(row); + } + + MergeCells mergeCells = null; + //if (xlWorksheet.MergedCells.Count > 0) + //{ + // mergeCells = new MergeCells() { Count = (UInt32Value)(UInt32)xlWorksheet.MergedCells.Count }; + // foreach (var merged in xlWorksheet.MergedCells) + // { + // MergeCell mergeCell = new MergeCell() { Reference = merged }; + // mergeCells.Append(mergeCell); + // } + //} + + PageMargins pageMargins = new PageMargins() { Left = 0.7D, Right = 0.7D, Top = 0.75D, Bottom = 0.75D, Header = 0.3D, Footer = 0.3D }; + Drawing drawing1 = new Drawing() { Id = "rId1" }; + worksheet.Append(sheetProperties); + worksheet.Append(sheetDimension); + worksheet.Append(sheetViews); + worksheet.Append(sheetFormatProperties3); + if (columns != null) worksheet.Append(columns); + worksheet.Append(sheetData); + if (mergeCells != null) worksheet.Append(mergeCells); + worksheet.Append(pageMargins); + //worksheet.Append(drawing1); + + worksheetPart.Worksheet = worksheet; + } + + private void GenerateThemePartContent(ThemePart themePart) + { + A.Theme theme1 = new A.Theme() { Name = "Office Theme" }; + theme1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); + + A.ThemeElements themeElements1 = new A.ThemeElements(); + + A.ColorScheme colorScheme1 = new A.ColorScheme() { Name = "Office" }; + + A.Dark1Color dark1Color1 = new A.Dark1Color(); + A.SystemColor systemColor1 = new A.SystemColor() { Val = A.SystemColorValues.WindowText, LastColor = "000000" }; + + dark1Color1.Append(systemColor1); + + A.Light1Color light1Color1 = new A.Light1Color(); + A.SystemColor systemColor2 = new A.SystemColor() { Val = A.SystemColorValues.Window, LastColor = "FFFFFF" }; + + light1Color1.Append(systemColor2); + + A.Dark2Color dark2Color1 = new A.Dark2Color(); + A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = "1F497D" }; + + dark2Color1.Append(rgbColorModelHex1); + + A.Light2Color light2Color1 = new A.Light2Color(); + A.RgbColorModelHex rgbColorModelHex2 = new A.RgbColorModelHex() { Val = "EEECE1" }; + + light2Color1.Append(rgbColorModelHex2); + + A.Accent1Color accent1Color1 = new A.Accent1Color(); + A.RgbColorModelHex rgbColorModelHex3 = new A.RgbColorModelHex() { Val = "4F81BD" }; + + accent1Color1.Append(rgbColorModelHex3); + + A.Accent2Color accent2Color1 = new A.Accent2Color(); + A.RgbColorModelHex rgbColorModelHex4 = new A.RgbColorModelHex() { Val = "C0504D" }; + + accent2Color1.Append(rgbColorModelHex4); + + A.Accent3Color accent3Color1 = new A.Accent3Color(); + A.RgbColorModelHex rgbColorModelHex5 = new A.RgbColorModelHex() { Val = "9BBB59" }; + + accent3Color1.Append(rgbColorModelHex5); + + A.Accent4Color accent4Color1 = new A.Accent4Color(); + A.RgbColorModelHex rgbColorModelHex6 = new A.RgbColorModelHex() { Val = "8064A2" }; + + accent4Color1.Append(rgbColorModelHex6); + + A.Accent5Color accent5Color1 = new A.Accent5Color(); + A.RgbColorModelHex rgbColorModelHex7 = new A.RgbColorModelHex() { Val = "4BACC6" }; + + accent5Color1.Append(rgbColorModelHex7); + + A.Accent6Color accent6Color1 = new A.Accent6Color(); + A.RgbColorModelHex rgbColorModelHex8 = new A.RgbColorModelHex() { Val = "F79646" }; + + accent6Color1.Append(rgbColorModelHex8); + + A.Hyperlink hyperlink1 = new A.Hyperlink(); + A.RgbColorModelHex rgbColorModelHex9 = new A.RgbColorModelHex() { Val = "0000FF" }; + + hyperlink1.Append(rgbColorModelHex9); + + A.FollowedHyperlinkColor followedHyperlinkColor1 = new A.FollowedHyperlinkColor(); + A.RgbColorModelHex rgbColorModelHex10 = new A.RgbColorModelHex() { Val = "800080" }; + + followedHyperlinkColor1.Append(rgbColorModelHex10); + + colorScheme1.Append(dark1Color1); + colorScheme1.Append(light1Color1); + colorScheme1.Append(dark2Color1); + colorScheme1.Append(light2Color1); + colorScheme1.Append(accent1Color1); + colorScheme1.Append(accent2Color1); + colorScheme1.Append(accent3Color1); + colorScheme1.Append(accent4Color1); + colorScheme1.Append(accent5Color1); + colorScheme1.Append(accent6Color1); + colorScheme1.Append(hyperlink1); + colorScheme1.Append(followedHyperlinkColor1); + + A.FontScheme fontScheme2 = new A.FontScheme() { Name = "Office" }; + + A.MajorFont majorFont1 = new A.MajorFont(); + A.LatinFont latinFont1 = new A.LatinFont() { Typeface = "Cambria" }; + A.EastAsianFont eastAsianFont1 = new A.EastAsianFont() { Typeface = "" }; + A.ComplexScriptFont complexScriptFont1 = new A.ComplexScriptFont() { Typeface = "" }; + A.SupplementalFont supplementalFont1 = new A.SupplementalFont() { Script = "Jpan", Typeface = "MS Pゴシック" }; + A.SupplementalFont supplementalFont2 = new A.SupplementalFont() { Script = "Hang", Typeface = "맑은 고딕" }; + A.SupplementalFont supplementalFont3 = new A.SupplementalFont() { Script = "Hans", Typeface = "宋体" }; + A.SupplementalFont supplementalFont4 = new A.SupplementalFont() { Script = "Hant", Typeface = "新細明體" }; + A.SupplementalFont supplementalFont5 = new A.SupplementalFont() { Script = "Arab", Typeface = "Times New Roman" }; + A.SupplementalFont supplementalFont6 = new A.SupplementalFont() { Script = "Hebr", Typeface = "Times New Roman" }; + A.SupplementalFont supplementalFont7 = new A.SupplementalFont() { Script = "Thai", Typeface = "Tahoma" }; + A.SupplementalFont supplementalFont8 = new A.SupplementalFont() { Script = "Ethi", Typeface = "Nyala" }; + A.SupplementalFont supplementalFont9 = new A.SupplementalFont() { Script = "Beng", Typeface = "Vrinda" }; + A.SupplementalFont supplementalFont10 = new A.SupplementalFont() { Script = "Gujr", Typeface = "Shruti" }; + A.SupplementalFont supplementalFont11 = new A.SupplementalFont() { Script = "Khmr", Typeface = "MoolBoran" }; + A.SupplementalFont supplementalFont12 = new A.SupplementalFont() { Script = "Knda", Typeface = "Tunga" }; + A.SupplementalFont supplementalFont13 = new A.SupplementalFont() { Script = "Guru", Typeface = "Raavi" }; + A.SupplementalFont supplementalFont14 = new A.SupplementalFont() { Script = "Cans", Typeface = "Euphemia" }; + A.SupplementalFont supplementalFont15 = new A.SupplementalFont() { Script = "Cher", Typeface = "Plantagenet Cherokee" }; + A.SupplementalFont supplementalFont16 = new A.SupplementalFont() { Script = "Yiii", Typeface = "Microsoft Yi Baiti" }; + A.SupplementalFont supplementalFont17 = new A.SupplementalFont() { Script = "Tibt", Typeface = "Microsoft Himalaya" }; + A.SupplementalFont supplementalFont18 = new A.SupplementalFont() { Script = "Thaa", Typeface = "MV Boli" }; + A.SupplementalFont supplementalFont19 = new A.SupplementalFont() { Script = "Deva", Typeface = "Mangal" }; + A.SupplementalFont supplementalFont20 = new A.SupplementalFont() { Script = "Telu", Typeface = "Gautami" }; + A.SupplementalFont supplementalFont21 = new A.SupplementalFont() { Script = "Taml", Typeface = "Latha" }; + A.SupplementalFont supplementalFont22 = new A.SupplementalFont() { Script = "Syrc", Typeface = "Estrangelo Edessa" }; + A.SupplementalFont supplementalFont23 = new A.SupplementalFont() { Script = "Orya", Typeface = "Kalinga" }; + A.SupplementalFont supplementalFont24 = new A.SupplementalFont() { Script = "Mlym", Typeface = "Kartika" }; + A.SupplementalFont supplementalFont25 = new A.SupplementalFont() { Script = "Laoo", Typeface = "DokChampa" }; + A.SupplementalFont supplementalFont26 = new A.SupplementalFont() { Script = "Sinh", Typeface = "Iskoola Pota" }; + A.SupplementalFont supplementalFont27 = new A.SupplementalFont() { Script = "Mong", Typeface = "Mongolian Baiti" }; + A.SupplementalFont supplementalFont28 = new A.SupplementalFont() { Script = "Viet", Typeface = "Times New Roman" }; + A.SupplementalFont supplementalFont29 = new A.SupplementalFont() { Script = "Uigh", Typeface = "Microsoft Uighur" }; + + majorFont1.Append(latinFont1); + majorFont1.Append(eastAsianFont1); + majorFont1.Append(complexScriptFont1); + majorFont1.Append(supplementalFont1); + majorFont1.Append(supplementalFont2); + majorFont1.Append(supplementalFont3); + majorFont1.Append(supplementalFont4); + majorFont1.Append(supplementalFont5); + majorFont1.Append(supplementalFont6); + majorFont1.Append(supplementalFont7); + majorFont1.Append(supplementalFont8); + majorFont1.Append(supplementalFont9); + majorFont1.Append(supplementalFont10); + majorFont1.Append(supplementalFont11); + majorFont1.Append(supplementalFont12); + majorFont1.Append(supplementalFont13); + majorFont1.Append(supplementalFont14); + majorFont1.Append(supplementalFont15); + majorFont1.Append(supplementalFont16); + majorFont1.Append(supplementalFont17); + majorFont1.Append(supplementalFont18); + majorFont1.Append(supplementalFont19); + majorFont1.Append(supplementalFont20); + majorFont1.Append(supplementalFont21); + majorFont1.Append(supplementalFont22); + majorFont1.Append(supplementalFont23); + majorFont1.Append(supplementalFont24); + majorFont1.Append(supplementalFont25); + majorFont1.Append(supplementalFont26); + majorFont1.Append(supplementalFont27); + majorFont1.Append(supplementalFont28); + majorFont1.Append(supplementalFont29); + + A.MinorFont minorFont1 = new A.MinorFont(); + A.LatinFont latinFont2 = new A.LatinFont() { Typeface = "Calibri" }; + A.EastAsianFont eastAsianFont2 = new A.EastAsianFont() { Typeface = "" }; + A.ComplexScriptFont complexScriptFont2 = new A.ComplexScriptFont() { Typeface = "" }; + A.SupplementalFont supplementalFont30 = new A.SupplementalFont() { Script = "Jpan", Typeface = "MS Pゴシック" }; + A.SupplementalFont supplementalFont31 = new A.SupplementalFont() { Script = "Hang", Typeface = "맑은 고딕" }; + A.SupplementalFont supplementalFont32 = new A.SupplementalFont() { Script = "Hans", Typeface = "宋体" }; + A.SupplementalFont supplementalFont33 = new A.SupplementalFont() { Script = "Hant", Typeface = "新細明體" }; + A.SupplementalFont supplementalFont34 = new A.SupplementalFont() { Script = "Arab", Typeface = "Arial" }; + A.SupplementalFont supplementalFont35 = new A.SupplementalFont() { Script = "Hebr", Typeface = "Arial" }; + A.SupplementalFont supplementalFont36 = new A.SupplementalFont() { Script = "Thai", Typeface = "Tahoma" }; + A.SupplementalFont supplementalFont37 = new A.SupplementalFont() { Script = "Ethi", Typeface = "Nyala" }; + A.SupplementalFont supplementalFont38 = new A.SupplementalFont() { Script = "Beng", Typeface = "Vrinda" }; + A.SupplementalFont supplementalFont39 = new A.SupplementalFont() { Script = "Gujr", Typeface = "Shruti" }; + A.SupplementalFont supplementalFont40 = new A.SupplementalFont() { Script = "Khmr", Typeface = "DaunPenh" }; + A.SupplementalFont supplementalFont41 = new A.SupplementalFont() { Script = "Knda", Typeface = "Tunga" }; + A.SupplementalFont supplementalFont42 = new A.SupplementalFont() { Script = "Guru", Typeface = "Raavi" }; + A.SupplementalFont supplementalFont43 = new A.SupplementalFont() { Script = "Cans", Typeface = "Euphemia" }; + A.SupplementalFont supplementalFont44 = new A.SupplementalFont() { Script = "Cher", Typeface = "Plantagenet Cherokee" }; + A.SupplementalFont supplementalFont45 = new A.SupplementalFont() { Script = "Yiii", Typeface = "Microsoft Yi Baiti" }; + A.SupplementalFont supplementalFont46 = new A.SupplementalFont() { Script = "Tibt", Typeface = "Microsoft Himalaya" }; + A.SupplementalFont supplementalFont47 = new A.SupplementalFont() { Script = "Thaa", Typeface = "MV Boli" }; + A.SupplementalFont supplementalFont48 = new A.SupplementalFont() { Script = "Deva", Typeface = "Mangal" }; + A.SupplementalFont supplementalFont49 = new A.SupplementalFont() { Script = "Telu", Typeface = "Gautami" }; + A.SupplementalFont supplementalFont50 = new A.SupplementalFont() { Script = "Taml", Typeface = "Latha" }; + A.SupplementalFont supplementalFont51 = new A.SupplementalFont() { Script = "Syrc", Typeface = "Estrangelo Edessa" }; + A.SupplementalFont supplementalFont52 = new A.SupplementalFont() { Script = "Orya", Typeface = "Kalinga" }; + A.SupplementalFont supplementalFont53 = new A.SupplementalFont() { Script = "Mlym", Typeface = "Kartika" }; + A.SupplementalFont supplementalFont54 = new A.SupplementalFont() { Script = "Laoo", Typeface = "DokChampa" }; + A.SupplementalFont supplementalFont55 = new A.SupplementalFont() { Script = "Sinh", Typeface = "Iskoola Pota" }; + A.SupplementalFont supplementalFont56 = new A.SupplementalFont() { Script = "Mong", Typeface = "Mongolian Baiti" }; + A.SupplementalFont supplementalFont57 = new A.SupplementalFont() { Script = "Viet", Typeface = "Arial" }; + A.SupplementalFont supplementalFont58 = new A.SupplementalFont() { Script = "Uigh", Typeface = "Microsoft Uighur" }; + + minorFont1.Append(latinFont2); + minorFont1.Append(eastAsianFont2); + minorFont1.Append(complexScriptFont2); + minorFont1.Append(supplementalFont30); + minorFont1.Append(supplementalFont31); + minorFont1.Append(supplementalFont32); + minorFont1.Append(supplementalFont33); + minorFont1.Append(supplementalFont34); + minorFont1.Append(supplementalFont35); + minorFont1.Append(supplementalFont36); + minorFont1.Append(supplementalFont37); + minorFont1.Append(supplementalFont38); + minorFont1.Append(supplementalFont39); + minorFont1.Append(supplementalFont40); + minorFont1.Append(supplementalFont41); + minorFont1.Append(supplementalFont42); + minorFont1.Append(supplementalFont43); + minorFont1.Append(supplementalFont44); + minorFont1.Append(supplementalFont45); + minorFont1.Append(supplementalFont46); + minorFont1.Append(supplementalFont47); + minorFont1.Append(supplementalFont48); + minorFont1.Append(supplementalFont49); + minorFont1.Append(supplementalFont50); + minorFont1.Append(supplementalFont51); + minorFont1.Append(supplementalFont52); + minorFont1.Append(supplementalFont53); + minorFont1.Append(supplementalFont54); + minorFont1.Append(supplementalFont55); + minorFont1.Append(supplementalFont56); + minorFont1.Append(supplementalFont57); + minorFont1.Append(supplementalFont58); + + fontScheme2.Append(majorFont1); + fontScheme2.Append(minorFont1); + + A.FormatScheme formatScheme1 = new A.FormatScheme() { Name = "Office" }; + + A.FillStyleList fillStyleList1 = new A.FillStyleList(); + + A.SolidFill solidFill1 = new A.SolidFill(); + A.SchemeColor schemeColor1 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + + solidFill1.Append(schemeColor1); + + A.GradientFill gradientFill1 = new A.GradientFill() { RotateWithShape = true }; + + A.GradientStopList gradientStopList1 = new A.GradientStopList(); + + A.GradientStop gradientStop1 = new A.GradientStop() { Position = 0 }; + + A.SchemeColor schemeColor2 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Tint tint1 = new A.Tint() { Val = 50000 }; + A.SaturationModulation saturationModulation1 = new A.SaturationModulation() { Val = 300000 }; + + schemeColor2.Append(tint1); + schemeColor2.Append(saturationModulation1); + + gradientStop1.Append(schemeColor2); + + A.GradientStop gradientStop2 = new A.GradientStop() { Position = 35000 }; + + A.SchemeColor schemeColor3 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Tint tint2 = new A.Tint() { Val = 37000 }; + A.SaturationModulation saturationModulation2 = new A.SaturationModulation() { Val = 300000 }; + + schemeColor3.Append(tint2); + schemeColor3.Append(saturationModulation2); + + gradientStop2.Append(schemeColor3); + + A.GradientStop gradientStop3 = new A.GradientStop() { Position = 100000 }; + + A.SchemeColor schemeColor4 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Tint tint3 = new A.Tint() { Val = 15000 }; + A.SaturationModulation saturationModulation3 = new A.SaturationModulation() { Val = 350000 }; + + schemeColor4.Append(tint3); + schemeColor4.Append(saturationModulation3); + + gradientStop3.Append(schemeColor4); + + gradientStopList1.Append(gradientStop1); + gradientStopList1.Append(gradientStop2); + gradientStopList1.Append(gradientStop3); + A.LinearGradientFill linearGradientFill1 = new A.LinearGradientFill() { Angle = 16200000, Scaled = true }; + + gradientFill1.Append(gradientStopList1); + gradientFill1.Append(linearGradientFill1); + + A.GradientFill gradientFill2 = new A.GradientFill() { RotateWithShape = true }; + + A.GradientStopList gradientStopList2 = new A.GradientStopList(); + + A.GradientStop gradientStop4 = new A.GradientStop() { Position = 0 }; + + A.SchemeColor schemeColor5 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Shade shade1 = new A.Shade() { Val = 51000 }; + A.SaturationModulation saturationModulation4 = new A.SaturationModulation() { Val = 130000 }; + + schemeColor5.Append(shade1); + schemeColor5.Append(saturationModulation4); + + gradientStop4.Append(schemeColor5); + + A.GradientStop gradientStop5 = new A.GradientStop() { Position = 80000 }; + + A.SchemeColor schemeColor6 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Shade shade2 = new A.Shade() { Val = 93000 }; + A.SaturationModulation saturationModulation5 = new A.SaturationModulation() { Val = 130000 }; + + schemeColor6.Append(shade2); + schemeColor6.Append(saturationModulation5); + + gradientStop5.Append(schemeColor6); + + A.GradientStop gradientStop6 = new A.GradientStop() { Position = 100000 }; + + A.SchemeColor schemeColor7 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Shade shade3 = new A.Shade() { Val = 94000 }; + A.SaturationModulation saturationModulation6 = new A.SaturationModulation() { Val = 135000 }; + + schemeColor7.Append(shade3); + schemeColor7.Append(saturationModulation6); + + gradientStop6.Append(schemeColor7); + + gradientStopList2.Append(gradientStop4); + gradientStopList2.Append(gradientStop5); + gradientStopList2.Append(gradientStop6); + A.LinearGradientFill linearGradientFill2 = new A.LinearGradientFill() { Angle = 16200000, Scaled = false }; + + gradientFill2.Append(gradientStopList2); + gradientFill2.Append(linearGradientFill2); + + fillStyleList1.Append(solidFill1); + fillStyleList1.Append(gradientFill1); + fillStyleList1.Append(gradientFill2); + + A.LineStyleList lineStyleList1 = new A.LineStyleList(); + + A.Outline outline1 = new A.Outline() { Width = 9525, CapType = A.LineCapValues.Flat, CompoundLineType = A.CompoundLineValues.Single, Alignment = A.PenAlignmentValues.Center }; + + A.SolidFill solidFill2 = new A.SolidFill(); + + A.SchemeColor schemeColor8 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Shade shade4 = new A.Shade() { Val = 95000 }; + A.SaturationModulation saturationModulation7 = new A.SaturationModulation() { Val = 105000 }; + + schemeColor8.Append(shade4); + schemeColor8.Append(saturationModulation7); + + solidFill2.Append(schemeColor8); + A.PresetDash presetDash1 = new A.PresetDash() { Val = A.PresetLineDashValues.Solid }; + + outline1.Append(solidFill2); + outline1.Append(presetDash1); + + A.Outline outline2 = new A.Outline() { Width = 25400, CapType = A.LineCapValues.Flat, CompoundLineType = A.CompoundLineValues.Single, Alignment = A.PenAlignmentValues.Center }; + + A.SolidFill solidFill3 = new A.SolidFill(); + A.SchemeColor schemeColor9 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + + solidFill3.Append(schemeColor9); + A.PresetDash presetDash2 = new A.PresetDash() { Val = A.PresetLineDashValues.Solid }; + + outline2.Append(solidFill3); + outline2.Append(presetDash2); + + A.Outline outline3 = new A.Outline() { Width = 38100, CapType = A.LineCapValues.Flat, CompoundLineType = A.CompoundLineValues.Single, Alignment = A.PenAlignmentValues.Center }; + + A.SolidFill solidFill4 = new A.SolidFill(); + A.SchemeColor schemeColor10 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + + solidFill4.Append(schemeColor10); + A.PresetDash presetDash3 = new A.PresetDash() { Val = A.PresetLineDashValues.Solid }; + + outline3.Append(solidFill4); + outline3.Append(presetDash3); + + lineStyleList1.Append(outline1); + lineStyleList1.Append(outline2); + lineStyleList1.Append(outline3); + + A.EffectStyleList effectStyleList1 = new A.EffectStyleList(); + + A.EffectStyle effectStyle1 = new A.EffectStyle(); + + A.EffectList effectList1 = new A.EffectList(); + + A.OuterShadow outerShadow1 = new A.OuterShadow() { BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false }; + + A.RgbColorModelHex rgbColorModelHex11 = new A.RgbColorModelHex() { Val = "000000" }; + A.Alpha alpha1 = new A.Alpha() { Val = 38000 }; + + rgbColorModelHex11.Append(alpha1); + + outerShadow1.Append(rgbColorModelHex11); + + effectList1.Append(outerShadow1); + + effectStyle1.Append(effectList1); + + A.EffectStyle effectStyle2 = new A.EffectStyle(); + + A.EffectList effectList2 = new A.EffectList(); + + A.OuterShadow outerShadow2 = new A.OuterShadow() { BlurRadius = 40000L, Distance = 23000L, Direction = 5400000, RotateWithShape = false }; + + A.RgbColorModelHex rgbColorModelHex12 = new A.RgbColorModelHex() { Val = "000000" }; + A.Alpha alpha2 = new A.Alpha() { Val = 35000 }; + + rgbColorModelHex12.Append(alpha2); + + outerShadow2.Append(rgbColorModelHex12); + + effectList2.Append(outerShadow2); + + effectStyle2.Append(effectList2); + + A.EffectStyle effectStyle3 = new A.EffectStyle(); + + A.EffectList effectList3 = new A.EffectList(); + + A.OuterShadow outerShadow3 = new A.OuterShadow() { BlurRadius = 40000L, Distance = 23000L, Direction = 5400000, RotateWithShape = false }; + + A.RgbColorModelHex rgbColorModelHex13 = new A.RgbColorModelHex() { Val = "000000" }; + A.Alpha alpha3 = new A.Alpha() { Val = 35000 }; + + rgbColorModelHex13.Append(alpha3); + + outerShadow3.Append(rgbColorModelHex13); + + effectList3.Append(outerShadow3); + + A.Scene3DType scene3DType1 = new A.Scene3DType(); + + A.Camera camera1 = new A.Camera() { Preset = A.PresetCameraValues.OrthographicFront }; + A.Rotation rotation1 = new A.Rotation() { Latitude = 0, Longitude = 0, Revolution = 0 }; + + camera1.Append(rotation1); + + A.LightRig lightRig1 = new A.LightRig() { Rig = A.LightRigValues.ThreePoints, Direction = A.LightRigDirectionValues.Top }; + A.Rotation rotation2 = new A.Rotation() { Latitude = 0, Longitude = 0, Revolution = 1200000 }; + + lightRig1.Append(rotation2); + + scene3DType1.Append(camera1); + scene3DType1.Append(lightRig1); + + A.Shape3DType shape3DType1 = new A.Shape3DType(); + A.BevelTop bevelTop1 = new A.BevelTop() { Width = 63500L, Height = 25400L }; + + shape3DType1.Append(bevelTop1); + + effectStyle3.Append(effectList3); + effectStyle3.Append(scene3DType1); + effectStyle3.Append(shape3DType1); + + effectStyleList1.Append(effectStyle1); + effectStyleList1.Append(effectStyle2); + effectStyleList1.Append(effectStyle3); + + A.BackgroundFillStyleList backgroundFillStyleList1 = new A.BackgroundFillStyleList(); + + A.SolidFill solidFill5 = new A.SolidFill(); + A.SchemeColor schemeColor11 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + + solidFill5.Append(schemeColor11); + + A.GradientFill gradientFill3 = new A.GradientFill() { RotateWithShape = true }; + + A.GradientStopList gradientStopList3 = new A.GradientStopList(); + + A.GradientStop gradientStop7 = new A.GradientStop() { Position = 0 }; + + A.SchemeColor schemeColor12 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Tint tint4 = new A.Tint() { Val = 40000 }; + A.SaturationModulation saturationModulation8 = new A.SaturationModulation() { Val = 350000 }; + + schemeColor12.Append(tint4); + schemeColor12.Append(saturationModulation8); + + gradientStop7.Append(schemeColor12); + + A.GradientStop gradientStop8 = new A.GradientStop() { Position = 40000 }; + + A.SchemeColor schemeColor13 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Tint tint5 = new A.Tint() { Val = 45000 }; + A.Shade shade5 = new A.Shade() { Val = 99000 }; + A.SaturationModulation saturationModulation9 = new A.SaturationModulation() { Val = 350000 }; + + schemeColor13.Append(tint5); + schemeColor13.Append(shade5); + schemeColor13.Append(saturationModulation9); + + gradientStop8.Append(schemeColor13); + + A.GradientStop gradientStop9 = new A.GradientStop() { Position = 100000 }; + + A.SchemeColor schemeColor14 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Shade shade6 = new A.Shade() { Val = 20000 }; + A.SaturationModulation saturationModulation10 = new A.SaturationModulation() { Val = 255000 }; + + schemeColor14.Append(shade6); + schemeColor14.Append(saturationModulation10); + + gradientStop9.Append(schemeColor14); + + gradientStopList3.Append(gradientStop7); + gradientStopList3.Append(gradientStop8); + gradientStopList3.Append(gradientStop9); + + A.PathGradientFill pathGradientFill1 = new A.PathGradientFill() { Path = A.PathShadeValues.Circle }; + A.FillToRectangle fillToRectangle1 = new A.FillToRectangle() { Left = 50000, Top = -80000, Right = 50000, Bottom = 180000 }; + + pathGradientFill1.Append(fillToRectangle1); + + gradientFill3.Append(gradientStopList3); + gradientFill3.Append(pathGradientFill1); + + A.GradientFill gradientFill4 = new A.GradientFill() { RotateWithShape = true }; + + A.GradientStopList gradientStopList4 = new A.GradientStopList(); + + A.GradientStop gradientStop10 = new A.GradientStop() { Position = 0 }; + + A.SchemeColor schemeColor15 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Tint tint6 = new A.Tint() { Val = 80000 }; + A.SaturationModulation saturationModulation11 = new A.SaturationModulation() { Val = 300000 }; + + schemeColor15.Append(tint6); + schemeColor15.Append(saturationModulation11); + + gradientStop10.Append(schemeColor15); + + A.GradientStop gradientStop11 = new A.GradientStop() { Position = 100000 }; + + A.SchemeColor schemeColor16 = new A.SchemeColor() { Val = A.SchemeColorValues.PhColor }; + A.Shade shade7 = new A.Shade() { Val = 30000 }; + A.SaturationModulation saturationModulation12 = new A.SaturationModulation() { Val = 200000 }; + + schemeColor16.Append(shade7); + schemeColor16.Append(saturationModulation12); + + gradientStop11.Append(schemeColor16); + + gradientStopList4.Append(gradientStop10); + gradientStopList4.Append(gradientStop11); + + A.PathGradientFill pathGradientFill2 = new A.PathGradientFill() { Path = A.PathShadeValues.Circle }; + A.FillToRectangle fillToRectangle2 = new A.FillToRectangle() { Left = 50000, Top = 50000, Right = 50000, Bottom = 50000 }; + + pathGradientFill2.Append(fillToRectangle2); + + gradientFill4.Append(gradientStopList4); + gradientFill4.Append(pathGradientFill2); + + backgroundFillStyleList1.Append(solidFill5); + backgroundFillStyleList1.Append(gradientFill3); + backgroundFillStyleList1.Append(gradientFill4); + + formatScheme1.Append(fillStyleList1); + formatScheme1.Append(lineStyleList1); + formatScheme1.Append(effectStyleList1); + formatScheme1.Append(backgroundFillStyleList1); + + themeElements1.Append(colorScheme1); + themeElements1.Append(fontScheme2); + themeElements1.Append(formatScheme1); + A.ObjectDefaults objectDefaults1 = new A.ObjectDefaults(); + A.ExtraColorSchemeList extraColorSchemeList1 = new A.ExtraColorSchemeList(); + + theme1.Append(themeElements1); + theme1.Append(objectDefaults1); + theme1.Append(extraColorSchemeList1); + + themePart.Theme = theme1; + } + + private void SetPackageProperties(OpenXmlPackage document) + { + document.PackageProperties.Creator = Environment.UserName; + document.PackageProperties.Created = DateTime.Now; + document.PackageProperties.Modified = DateTime.Now; + document.PackageProperties.LastModifiedBy = Environment.UserName; + } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorksheet.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorksheet.cs new file mode 100644 index 0000000..f03de68 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorksheet.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel.Style; + +namespace ClosedXML.Excel +{ + public class XLWorksheet: IXLWorksheet + { + #region Constants + + public const Int32 MaxNumberOfRows = 1048576; + public const Int32 MaxNumberOfColumns = 16384; + + #endregion + + Dictionary cellsCollection = new Dictionary(); + + public XLWorksheet(String sheetName) + { + var defaultAddress = new XLAddress(0,0); + DefaultCell = new XLCell(defaultAddress, XLWorkbook.DefaultStyle); + cellsCollection.Add(defaultAddress, DefaultCell); + this.Name = sheetName; + } + + #region IXLRange Members + + public Dictionary CellsCollection + { + get { return cellsCollection; } + } + + public IXLAddress FirstCellAddress + { + get { return new XLAddress(1, 1); } + } + + public IXLAddress LastCellAddress + { + get { return new XLAddress(MaxNumberOfRows, MaxNumberOfColumns); } + } + + private IXLCell DefaultCell { get; set; } + + #endregion + + #region IXLStylized Members + + public IXLStyle Style + { + get + { + return DefaultCell.Style; + } + set + { + DefaultCell.Style = value; + } + } + + public IEnumerable Styles + { + get + { + UpdatingStyle = true; + foreach (var c in cellsCollection.Values) + { + yield return c.Style; + } + UpdatingStyle = false; + } + } + + public Boolean UpdatingStyle { get; set; } + + #endregion + + public IXLRange Row(Int32 row) + { + return new XLRow(row, cellsCollection, Style); + } + public IXLColumn Column(Int32 column) + { + return new XLColumn(column, cellsCollection, Style); + } + public IXLColumn Column(String column) + { + return new XLColumn(XLAddress.GetColumnNumberFromLetter(column), cellsCollection, Style); + } + + #region IXLRange Members + + + IXLRange IXLRange.Column(int column) + { + IXLAddress firstCellAddress = new XLAddress(1, column); + IXLAddress lastCellAddress = new XLAddress(MaxNumberOfRows, column); + return this.Range(firstCellAddress, lastCellAddress); + } + + IXLRange IXLRange.Column(string column) + { + IXLAddress firstCellAddress = new XLAddress(1, column); + IXLAddress lastCellAddress = new XLAddress(MaxNumberOfRows, column); + return this.Range(firstCellAddress, lastCellAddress); + } + + #endregion + + + public String Name { get; set; } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorksheets.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorksheets.cs new file mode 100644 index 0000000..5db3550 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorksheets.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ClosedXML.Excel +{ + public class XLWorksheets: IXLWorksheets + { + Dictionary worksheets = new Dictionary(); + + #region IXLWorksheets Members + + public IXLWorksheet GetWorksheet(string sheetName) + { + return worksheets[sheetName]; + } + + public IXLWorksheet GetWorksheet(int sheetIndex) + { + return worksheets.ElementAt(sheetIndex).Value; + } + + public IXLWorksheet Add(String sheetName) + { + var sheet = new XLWorksheet(sheetName); + worksheets.Add(sheetName, sheet); + return sheet; + } + + public void Delete(string sheetName) + { + worksheets.Remove(sheetName); + } + + #endregion + + #region IEnumerable Members + + public IEnumerator GetEnumerator() + { + return worksheets.Values.GetEnumerator(); + } + + #endregion + + #region IEnumerable Members + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + + + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML/Extensions.cs b/ClosedXML/ClosedXML/ClosedXML/Extensions.cs new file mode 100644 index 0000000..70bb1fe --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Extensions.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace ClosedXML +{ + public static class Extensions + { + // Adds the .ForEach method to all IEnumerables + public static void ForEach(this IEnumerable source, Action action) + { + foreach (T item in source) + action(item); + } + + static char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + + public static String ToHex(this Color color) + { + + byte[] bytes = new byte[4]; + + bytes[0] = color.A; + + bytes[1] = color.R; + + bytes[2] = color.G; + + bytes[3] = color.B; + + char[] chars = new char[bytes.Length * 2]; + + for (int i = 0; i < bytes.Length; i++) + { + + int b = bytes[i]; + + chars[i * 2] = hexDigits[b >> 4]; + + chars[i * 2 + 1] = hexDigits[b & 0xF]; + + } + + return new string(chars); + + } + + public static String RemoveSpecialCharacters(this String str) + { + StringBuilder sb = new StringBuilder(); + foreach (char c in str) + { + //if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') | c == '.' || c == '_') + if (Char.IsLetterOrDigit(c)) + { + sb.Append(c); + } + } + return sb.ToString(); + } + + } +} + diff --git a/ClosedXML/ClosedXML/ClosedXML/Properties/AssemblyInfo.cs b/ClosedXML/ClosedXML/ClosedXML/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..367a544 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ClosedXML")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("ClosedXML")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8747331d-de58-4621-8c7f-a7d57ca3467a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/BasicTable.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/BasicTable.cs new file mode 100644 index 0000000..621bb45 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Examples/BasicTable.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel; +using ClosedXML.Excel.Style; + +namespace ClosedXML_Examples +{ + public class BasicTable + { + public void Create(String filePath) + { + var workbook = new XLWorkbook(); + var ws = workbook.Worksheets.Add("Contacts"); + + //First Names + ws.Cell("A1").Value = "FName"; + ws.Cell("A2").Value = "John"; + ws.Cell("A3").Value = "Hank"; + ws.Cell("A4").Value = "Dagny"; + //Last Names + ws.Cell("B1").Value = "LName"; + ws.Cell("B2").Value = "Galt"; + ws.Cell("B3").Value = "Rearden"; + ws.Cell("B4").Value = "Taggart"; + //Is an outcast? + ws.Cell("C1").Value = "Outcast"; + ws.Cell("C2").Value = true.ToString(); + ws.Cell("C3").Value = false.ToString(); + ws.Cell("C4").Value = false.ToString(); + //Date of Birth + ws.Cell("D1").Value = "DOB"; + ws.Cell("D2").Value = new DateTime(1919, 1, 21).ToString(); + ws.Cell("D3").Value = new DateTime(1907, 3, 4).ToString(); + ws.Cell("D4").Value = new DateTime(1921, 12, 15).ToString(); + //Income + ws.Cell("E1").Value = "Income"; + ws.Cell("E2").Value = "2000"; + ws.Cell("E3").Value = "40000"; + ws.Cell("E4").Value = "10000"; + + //var rngDates = ws.Range("D2:D4"); + //var rngNumbers = ws.Range("E2:E4"); + + //rngDates.Style.NumberFormat.Format = "mm-dd-yy"; + //rngNumbers.Style.NumberFormat.Format = "$ #,##0"; + + //var rngHeaders = ws.Range("A1:E1"); + //rngHeaders.Style.Font.Bold = true; + //rngHeaders.Style.Fill.BackgroundColor = "6BE8FF"; + + //var rngTable = ws.Range("A1:E4"); + //rngTable.Style.Border.BottomBorder = XLBorderStyleValues.Thin; + + workbook.SaveAs(filePath); + } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/ClosedXML_Examples.csproj b/ClosedXML/ClosedXML/ClosedXML_Examples/ClosedXML_Examples.csproj new file mode 100644 index 0000000..4b4e9ba --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Examples/ClosedXML_Examples.csproj @@ -0,0 +1,73 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {03A518D0-1CB7-488E-861C-C4E782B27A46} + Exe + Properties + ClosedXML_Examples + ClosedXML_Examples + v4.0 + Client + 512 + SAK + SAK + SAK + SAK + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + {BD5E6BFE-E837-4A35-BCA9-39667D873A20} + ClosedXML + + + + + \ No newline at end of file diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/ClosedXML_Examples.csproj.vspscc b/ClosedXML/ClosedXML/ClosedXML_Examples/ClosedXML_Examples.csproj.vspscc new file mode 100644 index 0000000..feffdec --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Examples/ClosedXML_Examples.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/HelloWorld.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/HelloWorld.cs new file mode 100644 index 0000000..8f8c993 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Examples/HelloWorld.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel; + +namespace ClosedXML_Examples +{ + public class HelloWorld + { + public void Create(String filePath) + { + var workbook = new XLWorkbook(); + var worksheet = workbook.Worksheets.Add("Sample Sheet"); + worksheet.Cell("A1").Value = "Hello World!"; + workbook.SaveAs(filePath); + } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/Program.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/Program.cs new file mode 100644 index 0000000..1b591ad --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Examples/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML_Examples.Styles; + +namespace ClosedXML_Examples +{ + class Program + { + 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"); + + //var basicTable = new BasicTable(); + //basicTable.Create(@"c:\BasicTable.xlsx"); + } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/Properties/AssemblyInfo.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d492c06 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Examples/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ClosedXML_Examples")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("ClosedXML_Examples")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("603cd89c-23f2-415e-8afc-2e9ab7a4c372")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/Styles/StyleBorder.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/Styles/StyleBorder.cs new file mode 100644 index 0000000..80ff9a7 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Examples/Styles/StyleBorder.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel.Style; +using ClosedXML.Excel; +using System.Drawing; + +namespace ClosedXML_Examples.Styles +{ + public class StyleBorder + { + public void Create(String filePath) + { + var workbook = new XLWorkbook(); + var ws = workbook.Worksheets.Add("Style Border"); + + var co = 2; + var ro = 1; + + ws.Cell(++ro, co).Value = "BottomBorder = Thick; BottomBorderColor = Red"; + ws.Cell(ro, co).Style.Border.BottomBorder = XLBorderStyleValues.Thick; + ws.Cell(ro, co).Style.Border.BottomBorderColor = Color.Red; + + ws.Cell(++ro, co).Value = "TopBorder = Thick; TopBorderColor = Red"; + ws.Cell(ro, co).Style.Border.TopBorder = XLBorderStyleValues.Thick; + ws.Cell(ro, co).Style.Border.TopBorderColor = Color.Red; + + ws.Cell(++ro, co).Value = "LeftBorder = Thick; LeftBorderColor = Red"; + ws.Cell(ro, co).Style.Border.LeftBorder = XLBorderStyleValues.Thick; + ws.Cell(ro, co).Style.Border.LeftBorderColor = Color.Red; + + ws.Cell(++ro, co).Value = "RightBorder = Thick; RightBorderColor = Red"; + ws.Cell(ro, co).Style.Border.RightBorder = XLBorderStyleValues.Thick; + ws.Cell(ro, co).Style.Border.RightBorderColor = Color.Red; + + ws.Cell(++ro, co).Value = "DiagonalBorder = Thick; DiagonalBorderColor = Red; DiagonalUp = true"; + ws.Cell(ro, co).Style.Border.DiagonalBorder = XLBorderStyleValues.Thick; + ws.Cell(ro, co).Style.Border.DiagonalBorderColor = Color.Red; + ws.Cell(ro, co).Style.Border.DiagonalUp = true; + + ws.Cell(++ro, co).Value = "DiagonalBorder = Thick; DiagonalBorderColor = Red; DiagonalDown = true"; + ws.Cell(ro, co).Style.Border.DiagonalBorder = XLBorderStyleValues.Thick; + ws.Cell(ro, co).Style.Border.DiagonalBorderColor = Color.Red; + ws.Cell(ro, co).Style.Border.DiagonalDown = true; + + ws.Cell(++ro, co).Value = "DiagonalBorder = Thick; DiagonalBorderColor = Red; DiagonalUp = true; DiagonalDown = true"; + ws.Cell(ro, co).Style.Border.DiagonalBorder = XLBorderStyleValues.Thick; + ws.Cell(ro, co).Style.Border.DiagonalBorderColor = Color.Red; + ws.Cell(ro, co).Style.Border.DiagonalUp = true; + ws.Cell(ro, co).Style.Border.DiagonalDown = true; + + workbook.SaveAs(filePath); + } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/Styles/StyleFill.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/Styles/StyleFill.cs new file mode 100644 index 0000000..d67188d --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Examples/Styles/StyleFill.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel; +using System.Drawing; +using ClosedXML.Excel.Style; + +namespace ClosedXML_Examples.Styles +{ + public class StyleFill + { + public void Create(String filePath) + { + var workbook = new XLWorkbook(); + var ws = workbook.Worksheets.Add("Style Fill"); + + var co = 2; + var ro = 1; + + ws.Cell(++ro, co).Value = "BackgroundColor = Red"; + ws.Cell(ro, co).Style.Fill.BackgroundColor = Color.Red; + + ws.Cell(++ro, co).Value = "PatternType = DarkTrellis; PatternColor = Red; PatternBackgroundColor = Blue"; + ws.Cell(ro, co).Style.Fill.PatternType = XLFillPatternValues.DarkTrellis; + ws.Cell(ro, co).Style.Fill.PatternColor = Color.Red; + ws.Cell(ro, co).Style.Fill.PatternBackgroundColor = Color.Blue; + + workbook.SaveAs(filePath); + } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/Styles/StyleFont.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/Styles/StyleFont.cs new file mode 100644 index 0000000..7e9ae00 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Examples/Styles/StyleFont.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel; +using System.Drawing; +using ClosedXML.Excel.Style; + +namespace ClosedXML_Examples.Styles +{ + public class StyleFont + { + public void Create(String filePath) + { + var workbook = new XLWorkbook(); + var ws = workbook.Worksheets.Add("Style Font"); + + var co = 2; + var ro = 1; + + ws.Cell(++ro, co).Value = "Bold"; + ws.Cell(ro, co).Style.Font.Bold = true; + + ws.Cell(++ro, co).Value = "FontColor - Red"; + ws.Cell(ro, co).Style.Font.FontColor = Color.Red; + + ws.Cell(++ro, co).Value = "FontFamilyNumbering - Swiss"; + ws.Cell(ro, co).Style.Font.FontFamilyNumbering = XLFontFamilyNumberingValues.Swiss; + + ws.Cell(++ro, co).Value = "FontName - Arial"; + ws.Cell(ro, co).Style.Font.FontName = "Arial"; + + ws.Cell(++ro, co).Value = "FontSize = 8"; + ws.Cell(ro, co).Style.Font.FontSize = 8; + + ws.Cell(++ro, co).Value = "Italic"; + ws.Cell(ro, co).Style.Font.Italic = true; + + ws.Cell(++ro, co).Value = "Shadow"; + ws.Cell(ro, co).Style.Font.Shadow = true; + + ws.Cell(++ro, co).Value = "Strikethrough"; + ws.Cell(ro, co).Style.Font.Strikethrough = true; + + ws.Cell(++ro, co).Value = "Underline = Double"; + ws.Cell(ro, co).Style.Font.Underline = XLFontUnderlineValues.Double; + + ws.Cell(++ro, co).Value = "VerticalAlignment = Superscript"; + ws.Cell(ro, co).Style.Font.VerticalAlignment = XLFontVerticalTextAlignmentValues.Superscript; + + ws.Cell(++ro, co).Value = "Combined"; + ws.Cell(ro, co).Style.Font.Bold = true; + ws.Cell(ro, co).Style.Font.FontColor = Color.Red; + ws.Cell(ro, co).Style.Font.FontFamilyNumbering = XLFontFamilyNumberingValues.Swiss; + ws.Cell(ro, co).Style.Font.FontName = "Arial"; + ws.Cell(ro, co).Style.Font.FontSize = 8; + ws.Cell(ro, co).Style.Font.Italic = true; + ws.Cell(ro, co).Style.Font.Shadow = true; + ws.Cell(ro, co).Style.Font.Strikethrough = true; + ws.Cell(ro, co).Style.Font.Underline = XLFontUnderlineValues.Double; + ws.Cell(ro, co).Style.Font.VerticalAlignment = XLFontVerticalTextAlignmentValues.Superscript; + + + workbook.SaveAs(filePath); + } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML_Sandbox/ClosedXML_Sandbox.csproj b/ClosedXML/ClosedXML/ClosedXML_Sandbox/ClosedXML_Sandbox.csproj new file mode 100644 index 0000000..ff83f9e --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Sandbox/ClosedXML_Sandbox.csproj @@ -0,0 +1,67 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {38B882F0-E6F2-45C5-9BE9-CDC27FBEB4AB} + Exe + Properties + ClosedXML_Sandbox + ClosedXML_Sandbox + v4.0 + Client + 512 + SAK + SAK + SAK + SAK + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + {BD5E6BFE-E837-4A35-BCA9-39667D873A20} + ClosedXML + + + + + \ No newline at end of file diff --git a/ClosedXML/ClosedXML/ClosedXML_Sandbox/ClosedXML_Sandbox.csproj.vspscc b/ClosedXML/ClosedXML/ClosedXML_Sandbox/ClosedXML_Sandbox.csproj.vspscc new file mode 100644 index 0000000..feffdec --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Sandbox/ClosedXML_Sandbox.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs b/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs new file mode 100644 index 0000000..3c49e4e --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ClosedXML.Excel; +using ClosedXML.Excel.Style; + +namespace ClosedXML_Sandbox +{ + class Program + { + static void Main(string[] args) + { + var wb = new XLWorkbook(); + var ws = wb.Worksheets.Add("New Sheet"); + ws.Cell(2, 2).Value = "Hello!"; + ws.Cell(2, 2).Style.Font.Bold = true; + wb.SaveAs(@"c:\Sandbox.xlsx"); + //Console.ReadKey(); + } + } +} diff --git a/ClosedXML/ClosedXML/ClosedXML_Sandbox/Properties/AssemblyInfo.cs b/ClosedXML/ClosedXML/ClosedXML_Sandbox/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..942db94 --- /dev/null +++ b/ClosedXML/ClosedXML/ClosedXML_Sandbox/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ClosedXML_Sandbox")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("ClosedXML_Sandbox")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7a3783fd-4e1b-4c17-a745-e6bbb593bd45")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ClosedXML/ClosedXML/Local.testsettings b/ClosedXML/ClosedXML/Local.testsettings new file mode 100644 index 0000000..49edf89 --- /dev/null +++ b/ClosedXML/ClosedXML/Local.testsettings @@ -0,0 +1,10 @@ + + + These are default test settings for a local test run. + + + + + + + \ No newline at end of file diff --git a/ClosedXML/ClosedXML/TraceAndTestImpact.testsettings b/ClosedXML/ClosedXML/TraceAndTestImpact.testsettings new file mode 100644 index 0000000..0792b9b --- /dev/null +++ b/ClosedXML/ClosedXML/TraceAndTestImpact.testsettings @@ -0,0 +1,21 @@ + + + These are test settings for Trace and Test Impact. + + + + + + + + + + + + + + + + + + \ No newline at end of file