diff --git a/ClosedXML/ClosedXML/ClosedXML/ClosedXML.csproj b/ClosedXML/ClosedXML/ClosedXML/ClosedXML.csproj
index a0d026e..9245108 100644
--- a/ClosedXML/ClosedXML/ClosedXML/ClosedXML.csproj
+++ b/ClosedXML/ClosedXML/ClosedXML/ClosedXML.csproj
@@ -121,9 +121,9 @@
-
+
-
+
@@ -156,10 +156,13 @@
+
+
+
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/XLCell.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/XLCell.cs
index 4c90564..9f87f82 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/XLCell.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Cells/XLCell.cs
@@ -764,7 +764,9 @@
format = formatCodes[Style.NumberFormat.NumberFormatId];
else
format = Style.NumberFormat.Format;
- cellValue = Double.Parse(cellValue).ToString(format);
+
+ if (!StringExtensions.IsNullOrWhiteSpace(format) && format != "@")
+ cellValue = Double.Parse(cellValue).ToString(format);
}
else if (dataType == XLCellValues.DateTime)
{
@@ -1123,8 +1125,7 @@
{
this.cellValue = source.cellValue;
this.dataType = source.dataType;
- this.formulaA1 = source.formulaA1;
- this.formulaR1C1 = source.formulaR1C1;
+ this.FormulaR1C1 = source.FormulaR1C1;
}
public IXLCell CopyFrom(IXLCell otherCell)
@@ -1132,9 +1133,9 @@
var source = otherCell as XLCell;
cellValue = source.cellValue;
dataType = source.dataType;
- formulaA1 = source.formulaA1;
- formulaR1C1 = source.formulaR1C1;
+ FormulaR1C1 = source.FormulaR1C1;
style = new XLStyle(this, source.style);
+
if (source.hyperlink != null)
{
SettingHyperlink = true;
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLChart.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLChart.cs
index 01d1def..726e418 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLChart.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLChart.cs
@@ -5,8 +5,89 @@
namespace ClosedXML.Excel
{
- public interface IXLChart
+ public enum XLChartType {
+ Area,
+ Area3D,
+ AreaStacked,
+ AreaStacked100Percent,
+ AreaStacked100Percent3D,
+ AreaStacked3D,
+ BarClustered,
+ BarClustered3D,
+ BarStacked,
+ BarStacked100Percent,
+ BarStacked100Percent3D,
+ BarStacked3D,
+ Bubble,
+ Bubble3D,
+ Column3D,
+ ColumnClustered,
+ ColumnClustered3D,
+ ColumnStacked,
+ ColumnStacked100Percent,
+ ColumnStacked100Percent3D,
+ ColumnStacked3D,
+ Cone,
+ ConeClustered,
+ ConeHorizontalClustered,
+ ConeHorizontalStacked,
+ ConeHorizontalStacked100Percent,
+ ConeStacked,
+ ConeStacked100Percent,
+ Cylinder,
+ CylinderClustered,
+ CylinderHorizontalClustered,
+ CylinderHorizontalStacked,
+ CylinderHorizontalStacked100Percent,
+ CylinderStacked,
+ CylinderStacked100Percent,
+ Doughnut,
+ DoughnutExploded,
+ Line,
+ Line3D,
+ LineStacked,
+ LineStacked100Percent,
+ LineWithMarkers,
+ LineWithMarkersStacked,
+ LineWithMarkersStacked100Percent,
+ Pie,
+ Pie3D,
+ PieExploded,
+ PieExploded3D,
+ PieToBar,
+ PieToPie,
+ Pyramid,
+ PyramidClustered,
+ PyramidHorizontalClustered,
+ PyramidHorizontalStacked,
+ PyramidHorizontalStacked100Percent,
+ PyramidStacked,
+ PyramidStacked100Percent,
+ Radar,
+ RadarFilled,
+ RadarWithMarkers,
+ StockHighLowClose,
+ StockOpenHighLowClose,
+ StockVolumeHighLowClose,
+ StockVolumeOpenHighLowClose,
+ Surface,
+ SurfaceContour,
+ SurfaceContourWireframe,
+ SurfaceWireframe,
+ XYScatterMarkers,
+ XYScatterSmoothLinesNoMarkers,
+ XYScatterSmoothLinesWithMarkers,
+ XYScatterStraightLinesNoMarkers,
+ XYScatterStraightLinesWithMarkers
+ }
+ public interface IXLChart: IXLDrawing
{
- IXLDrawingPosition Position { get; }
+ Boolean RightAngleAxes { get; set; }
+ IXLChart SetRightAngleAxes();
+ IXLChart SetRightAngleAxes(Boolean rightAngleAxes);
+
+ XLChartType ChartType { get; set; }
+ IXLChart SetChartType(XLChartType chartType);
+
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLCharts.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLCharts.cs
index af62fca..b42782d 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLCharts.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLCharts.cs
@@ -7,5 +7,6 @@
{
public interface IXLCharts: IEnumerable
{
+ void Add(IXLChart chart);
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLDrawing.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLDrawing.cs
new file mode 100644
index 0000000..e09dda4
--- /dev/null
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLDrawing.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ClosedXML.Excel
+{
+ public enum XLDrawingAnchor { MoveAndSizeWithCells, MoveWithCells, Absolute}
+ public interface IXLDrawing
+ {
+ Int32 Id { get; }
+
+ Boolean Hidden { get; set; }
+ T SetHidden();
+ T SetHidden(Boolean hidden);
+
+ String Name { get; set; }
+ T SetName(String name);
+
+ String Description { get; set; }
+ T SetDescription(String description);
+
+ XLDrawingAnchor Anchor { get; set; }
+
+ Int32 FirstColumn { get; set; }
+ T SetFirstColumn(Int32 firstColumn);
+ Int32 FirstColumnOffset { get; set; }
+ T SetFirstColumnOffset(Int32 firstColumnOffset);
+ Int32 FirstRow { get; set; }
+ T SetFirstRow(Int32 firstRow);
+ Int32 FirstRowOffset { get; set; }
+ T SetFirstRowOffset(Int32 firstRowOffset);
+
+ Int32 LastColumn { get; set; }
+ T SetLastColumn(Int32 firstColumn);
+ Int32 LastColumnOffset { get; set; }
+ T SetLastColumnOffset(Int32 firstColumn);
+ Int32 LastRow { get; set; }
+ T SetLastRow(Int32 firstRow);
+ Int32 LastRowOffset { get; set; }
+ T SetLastRowOffset(Int32 firstRowOffset);
+
+ Int32 ZOrder { get; set; }
+ T SetZOrder(Int32 zOrder);
+
+ Boolean HorizontalFlip { get; set; }
+ T SetHorizontalFlip();
+ T SetHorizontalFlip(Boolean horizontalFlip);
+
+ Boolean VerticalFlip { get; set; }
+ T SetVerticalFlip();
+ T SetVerticalFlip(Boolean verticalFlip);
+
+ Int32 Rotation { get; set; }
+ T SetRotation(Int32 rotation);
+
+ Int32 OffsetX { get; set; }
+ T SetOffsetX(Int32 offsetX);
+
+ Int32 OffsetY { get; set; }
+ T SetOffsetY(Int32 offsetY);
+
+ Int32 ExtentLength { get; set; }
+ T SetExtentLength(Int32 ExtentLength);
+
+ Int32 ExtentWidth { get; set; }
+ T SetExtentWidth(Int32 extentWidth);
+ }
+}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLDrawingPosition.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLDrawingPosition.cs
deleted file mode 100644
index bebd9e5..0000000
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/IXLDrawingPosition.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace ClosedXML.Excel
-{
- public enum XLDrawingAnchor { MoveAndSizeWithCells, MoveWithCells, Absolute}
- public interface IXLDrawingPosition
- {
- XLDrawingAnchor Anchor { get; set; }
- Int32 ZOrder { get; set; }
- }
-}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLChart.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLChart.cs
index 70d4ebc..d8324fc 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLChart.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLChart.cs
@@ -5,17 +5,158 @@
namespace ClosedXML.Excel
{
- internal class XLChart: IXLChart
+ internal enum XLChartTypeCategory { Bar3D }
+ internal enum XLBarOrientation { Vertical, Horizontal }
+ internal enum XLBarGrouping { Clustered, Percent, Stacked, Standard }
+ internal class XLChart: XLDrawing, IXLChart
{
- public XLChart()
+ internal IXLWorksheet worksheet;
+ public XLChart(XLWorksheet worksheet)
{
- Position = new XLDrawingPosition();
+ Container = this;
+ this.worksheet = worksheet;
+ Int32 zOrder;
+ if (worksheet.Charts.Any())
+ zOrder = worksheet.Charts.Max(c => c.ZOrder) + 1;
+ else
+ zOrder = 1;
+ ZOrder = zOrder;
+ Id = zOrder;
+ RightAngleAxes = true;
}
- IXLDrawingPosition Position { get; set; }
- IXLDrawingPosition IXLChart.Position
+ public Boolean RightAngleAxes { get; set; }
+ public IXLChart SetRightAngleAxes()
{
- get { throw new NotImplementedException(); }
+ RightAngleAxes = true;
+ return this;
}
+ public IXLChart SetRightAngleAxes(Boolean rightAngleAxes)
+ {
+ RightAngleAxes = rightAngleAxes;
+ return this;
+ }
+
+ public XLChartType ChartType { get; set; }
+ public IXLChart SetChartType(XLChartType chartType)
+ {
+ ChartType = chartType;
+ return this;
+ }
+
+ public XLChartTypeCategory ChartTypeCategory
+ {
+ get
+ {
+ if (Bar3DCharts.Contains(ChartType))
+ return XLChartTypeCategory.Bar3D;
+ else
+ throw new NotImplementedException();
+
+ }
+ }
+
+ private HashSet Bar3DCharts = new HashSet {
+ XLChartType.BarClustered3D,
+ XLChartType.BarStacked100Percent3D,
+ XLChartType.BarStacked3D,
+ XLChartType.Column3D,
+ XLChartType.ColumnClustered3D,
+ XLChartType.ColumnStacked100Percent3D,
+ XLChartType.ColumnStacked3D
+ };
+
+ public XLBarOrientation BarOrientation
+ {
+ get
+ {
+ if (HorizontalCharts.Contains(ChartType))
+ return XLBarOrientation.Horizontal;
+ else
+ return XLBarOrientation.Vertical;
+ }
+ }
+
+ private HashSet HorizontalCharts = new HashSet{
+ XLChartType.BarClustered,
+ XLChartType.BarClustered3D,
+ XLChartType.BarStacked,
+ XLChartType.BarStacked100Percent,
+ XLChartType.BarStacked100Percent3D,
+ XLChartType.BarStacked3D,
+ XLChartType.ConeHorizontalClustered,
+ XLChartType.ConeHorizontalStacked,
+ XLChartType.ConeHorizontalStacked100Percent,
+ XLChartType.CylinderHorizontalClustered,
+ XLChartType.CylinderHorizontalStacked,
+ XLChartType.CylinderHorizontalStacked100Percent,
+ XLChartType.PyramidHorizontalClustered,
+ XLChartType.PyramidHorizontalStacked,
+ XLChartType.PyramidHorizontalStacked100Percent
+ };
+
+ public XLBarGrouping BarGrouping
+ {
+ get
+ {
+ if (ClusteredCharts.Contains(ChartType))
+ return XLBarGrouping.Clustered;
+ else if (PercentCharts.Contains(ChartType))
+ return XLBarGrouping.Percent;
+ else if (StackedCharts.Contains(ChartType))
+ return XLBarGrouping.Stacked;
+ else
+ return XLBarGrouping.Standard;
+ }
+ }
+
+ public HashSet ClusteredCharts = new HashSet()
+ {
+ XLChartType.BarClustered,
+ XLChartType.BarClustered3D,
+ XLChartType.ColumnClustered,
+ XLChartType.ColumnClustered3D,
+ XLChartType.ConeClustered,
+ XLChartType.ConeHorizontalClustered,
+ XLChartType.CylinderClustered,
+ XLChartType.CylinderHorizontalClustered,
+ XLChartType.PyramidClustered,
+ XLChartType.PyramidHorizontalClustered
+ };
+
+ public HashSet PercentCharts = new HashSet() {
+ XLChartType.AreaStacked100Percent,
+ XLChartType.AreaStacked100Percent3D,
+ XLChartType.BarStacked100Percent,
+ XLChartType.BarStacked100Percent3D,
+ XLChartType.ColumnStacked100Percent,
+ XLChartType.ColumnStacked100Percent3D,
+ XLChartType.ConeHorizontalStacked100Percent,
+ XLChartType.ConeStacked100Percent,
+ XLChartType.CylinderHorizontalStacked100Percent,
+ XLChartType.CylinderStacked100Percent,
+ XLChartType.LineStacked100Percent,
+ XLChartType.LineWithMarkersStacked100Percent,
+ XLChartType.PyramidHorizontalStacked100Percent,
+ XLChartType.PyramidStacked100Percent
+ };
+
+ public HashSet StackedCharts = new HashSet()
+ {
+ XLChartType.AreaStacked,
+ XLChartType.AreaStacked3D,
+ XLChartType.BarStacked,
+ XLChartType.BarStacked3D,
+ XLChartType.ColumnStacked,
+ XLChartType.ColumnStacked3D,
+ XLChartType.ConeHorizontalStacked,
+ XLChartType.ConeStacked,
+ XLChartType.CylinderHorizontalStacked,
+ XLChartType.CylinderStacked,
+ XLChartType.LineStacked,
+ XLChartType.LineWithMarkersStacked,
+ XLChartType.PyramidHorizontalStacked,
+ XLChartType.PyramidStacked
+ };
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLCharts.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLCharts.cs
index e444b08..dfc94db 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLCharts.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLCharts.cs
@@ -7,14 +7,20 @@
{
internal class XLCharts: IXLCharts
{
+ private List charts = new List();
public IEnumerator GetEnumerator()
{
- throw new NotImplementedException();
+ return charts.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
- throw new NotImplementedException();
+ return GetEnumerator();
+ }
+
+ public void Add(IXLChart chart)
+ {
+ charts.Add(chart);
}
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLDrawing.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLDrawing.cs
new file mode 100644
index 0000000..379dcdb
--- /dev/null
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLDrawing.cs
@@ -0,0 +1,162 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ClosedXML.Excel
+{
+ internal class XLDrawing: IXLDrawing
+ {
+ internal T Container;
+ public XLDrawing()
+ {
+ Anchor = XLDrawingAnchor.MoveAndSizeWithCells;
+ }
+
+ public Int32 Id { get; internal set; }
+
+ public Boolean Hidden { get; set; }
+ public T SetHidden()
+ {
+ Hidden = true;
+ return Container;
+ }
+ public T SetHidden(Boolean hidden)
+ {
+ Hidden = hidden;
+ return Container;
+ }
+
+ public String Name { get; set; }
+ public T SetName(String name)
+ {
+ Name = name;
+ return Container;
+ }
+
+ public String Description { get; set; }
+ public T SetDescription(String description)
+ {
+ Description = description;
+ return Container;
+ }
+
+ public XLDrawingAnchor Anchor { get; set; }
+
+ public Int32 FirstColumn { get; set; }
+ public T SetFirstColumn(Int32 firstColumn)
+ {
+ FirstColumn = firstColumn;
+ return Container;
+ }
+ public Int32 FirstColumnOffset { get; set; }
+ public T SetFirstColumnOffset(Int32 firstColumnOffset)
+ {
+ FirstColumnOffset = firstColumnOffset;
+ return Container;
+ }
+ public Int32 FirstRow { get; set; }
+ public T SetFirstRow(Int32 firstRow)
+ {
+ FirstRow = firstRow;
+ return Container;
+ }
+ public Int32 FirstRowOffset { get; set; }
+ public T SetFirstRowOffset(Int32 firstRowOffset)
+ {
+ FirstRowOffset = firstRowOffset;
+ return Container;
+ }
+
+ public Int32 LastColumn { get; set; }
+ public T SetLastColumn(Int32 firstColumn)
+ {
+ LastColumn = firstColumn;
+ return Container;
+ }
+ public Int32 LastColumnOffset { get; set; }
+ public T SetLastColumnOffset(Int32 firstColumnOffset)
+ {
+ LastColumnOffset = firstColumnOffset;
+ return Container;
+ }
+ public Int32 LastRow { get; set; }
+ public T SetLastRow(Int32 firstRow)
+ {
+ LastRow = firstRow;
+ return Container;
+ }
+ public Int32 LastRowOffset { get; set; }
+ public T SetLastRowOffset(Int32 firstRowOffset)
+ {
+ LastRowOffset = firstRowOffset;
+ return Container;
+ }
+
+ public Int32 ZOrder { get; set; }
+ public T SetZOrder(Int32 zOrder)
+ {
+ ZOrder = zOrder;
+ return Container;
+ }
+
+ public Boolean HorizontalFlip { get; set; }
+ public T SetHorizontalFlip()
+ {
+ HorizontalFlip = true;
+ return Container;
+ }
+ public T SetHorizontalFlip(Boolean horizontalFlip)
+ {
+ HorizontalFlip = horizontalFlip;
+ return Container;
+ }
+
+ public Boolean VerticalFlip { get; set; }
+ public T SetVerticalFlip()
+ {
+ VerticalFlip = true;
+ return Container;
+ }
+ public T SetVerticalFlip(Boolean verticalFlip)
+ {
+ VerticalFlip = verticalFlip;
+ return Container;
+ }
+
+ public Int32 Rotation { get; set; }
+ public T SetRotation(Int32 rotation)
+ {
+ Rotation = rotation;
+ return Container;
+ }
+
+ public Int32 OffsetX { get; set; }
+ public T SetOffsetX(Int32 offsetX)
+ {
+ OffsetX = offsetX;
+ return Container;
+ }
+
+ public Int32 OffsetY { get; set; }
+ public T SetOffsetY(Int32 offsetY)
+ {
+ OffsetY = offsetY;
+ return Container;
+ }
+
+ public Int32 ExtentLength { get; set; }
+ public T SetExtentLength(Int32 extentLength)
+ {
+ ExtentLength = extentLength;
+ return Container;
+ }
+
+ public Int32 ExtentWidth { get; set; }
+ public T SetExtentWidth(Int32 extentWidth)
+ {
+ ExtentWidth = extentWidth;
+ return Container;
+ }
+ }
+}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLDrawingPosition.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLDrawingPosition.cs
deleted file mode 100644
index 6d11dd1..0000000
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Charts/XLDrawingPosition.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace ClosedXML.Excel
-{
- internal class XLDrawingPosition: IXLDrawingPosition
- {
- public XLDrawingAnchor Anchor
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public int ZOrder
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
- }
-}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/XLColumn.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/XLColumn.cs
index 6c23fb8..290c1b5 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/XLColumn.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/XLColumn.cs
@@ -547,7 +547,7 @@
public IXLRangeColumn Column(Int32 start, Int32 end)
{
- return AsRange().Range(start, 1, end, 1).Column(1);
+ return Range(start, 1, end, 1).Column(1);
}
public new IXLColumn Replace(String oldValue, String newValue)
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/IXLHFItem.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/IXLHFItem.cs
index 92e08c1..475cc41 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/IXLHFItem.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/IXLHFItem.cs
@@ -26,43 +26,27 @@
/// Adds the given text to this header/footer item.
///
/// The text to add to this header/footer item.
- void AddText(String text);
+ IXLRichText AddText(String text);
///
/// Adds the given predefined text to this header/footer item.
///
/// The predefined text to add to this header/footer item.
- void AddText(XLHFPredefinedText predefinedText);
+ IXLRichText AddText(XLHFPredefinedText predefinedText);
///
/// Adds the given text to this header/footer item.
///
/// The text to add to this header/footer item.
/// The occurrence for the text.
- void AddText(String text, XLHFOccurrence occurrence);
+ IXLRichText AddText(String text, XLHFOccurrence occurrence);
///
/// Adds the given predefined text to this header/footer item.
///
/// The predefined text to add to this header/footer item.
/// The occurrence for the predefined text.
- void AddText(XLHFPredefinedText predefinedText, XLHFOccurrence occurrence);
-
- ///
- /// Adds the given text to this header/footer item.
- ///
- /// The text to add to this header/footer item.
- /// The occurrence for the text.
- /// The font for the text.
- void AddText(String text, XLHFOccurrence occurrence, IXLFont xlFont);
-
- ///
- /// Adds the given predefined text to this header/footer item.
- ///
- /// The predefined text to add to this header/footer item.
- /// The occurrence for the predefined text.
- /// The font for the text.
- void AddText(XLHFPredefinedText predefinedText, XLHFOccurrence occurrence, IXLFont xlFont);
+ IXLRichText AddText(XLHFPredefinedText predefinedText, XLHFOccurrence occurrence);
/// Clears the text/formats of this header/footer item.
/// The occurrence to clear.
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/XLHFItem.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/XLHFItem.cs
index 2840a84..48fc77d 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/XLHFItem.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/XLHFItem.cs
@@ -13,64 +13,56 @@
{
defaultHFItem.texts.ForEach(kp => texts.Add(kp.Key, kp.Value));
}
- private Dictionary texts = new Dictionary();
+ private Dictionary> texts = new Dictionary>();
public String GetText(XLHFOccurrence occurrence)
{
+ var sb = new StringBuilder();
if(texts.ContainsKey(occurrence))
- return texts[occurrence];
+ {
+ foreach (var hfText in texts[occurrence])
+ sb.Append(hfText.HFText);
+ }
+
+ return sb.ToString();
+ }
+
+ public IXLRichText AddText(String text)
+ {
+ return AddText(text, XLHFOccurrence.AllPages);
+ }
+ public IXLRichText AddText(XLHFPredefinedText predefinedText)
+ {
+ return AddText(predefinedText, XLHFOccurrence.AllPages);
+ }
+
+ public IXLRichText AddText(String text, XLHFOccurrence occurrence)
+ {
+ IXLRichText richText = new XLRichText(text);
+
+ var hfText = new XLHFText(richText);
+ if (occurrence == XLHFOccurrence.AllPages)
+ {
+ AddTextToOccurrence(hfText, XLHFOccurrence.EvenPages);
+ AddTextToOccurrence(hfText, XLHFOccurrence.FirstPage);
+ AddTextToOccurrence(hfText, XLHFOccurrence.OddPages);
+ }
else
- return String.Empty;
- }
-
- public void AddText(String text)
- {
- AddText(text, XLHFOccurrence.AllPages);
- }
- public void AddText(XLHFPredefinedText predefinedText)
- {
- AddText(predefinedText, XLHFOccurrence.AllPages);
- }
- public void AddText(String text, XLHFOccurrence occurrence)
- {
- AddText(text, occurrence, null);
- }
- public void AddText(XLHFPredefinedText predefinedText, XLHFOccurrence occurrence)
- {
- AddText(predefinedText, occurrence, null);
- }
-
- public void AddText(String text, XLHFOccurrence occurrence, IXLFont xlFont)
- {
- if (text.Length > 0)
{
- var newText = xlFont != null ? GetHFFont(text, xlFont) : text;
- //var newText = hfFont + text;
- if (occurrence == XLHFOccurrence.AllPages)
- {
- AddTextToOccurrence(newText, XLHFOccurrence.EvenPages);
- AddTextToOccurrence(newText, XLHFOccurrence.FirstPage);
- AddTextToOccurrence(newText, XLHFOccurrence.OddPages);
- }
- else
- {
- AddTextToOccurrence(newText, occurrence);
- }
+ AddTextToOccurrence(hfText, occurrence);
}
+
+ return richText;
}
- private void AddTextToOccurrence(String text, XLHFOccurrence occurrence)
+ private void AddTextToOccurrence(XLHFText hfText, XLHFOccurrence occurrence)
{
- if (text.Length > 0)
- {
- var newText = text;
- if (texts.ContainsKey(occurrence))
- texts[occurrence] = texts[occurrence] + newText;
- else
- texts.Add(occurrence, newText);
- }
+ if (texts.ContainsKey(occurrence))
+ texts[occurrence].Add(hfText);
+ else
+ texts.Add(occurrence, new List() { hfText });
}
- public void AddText(XLHFPredefinedText predefinedText, XLHFOccurrence occurrence, IXLFont xlFont)
+ public IXLRichText AddText(XLHFPredefinedText predefinedText, XLHFOccurrence occurrence)
{
String hfText;
switch (predefinedText)
@@ -85,7 +77,7 @@
case XLHFPredefinedText.FullPath: hfText = "&Z&F"; break;
default: throw new NotImplementedException();
}
- AddText(hfText, occurrence, xlFont);
+ return AddText(hfText, occurrence);
}
public void Clear(XLHFOccurrence occurrence = XLHFOccurrence.AllPages)
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/XLHFText.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/XLHFText.cs
new file mode 100644
index 0000000..d53ab90
--- /dev/null
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/PageSetup/XLHFText.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ClosedXML.Excel
+{
+ internal class XLHFText
+ {
+ public XLHFText(IXLRichText richText)
+ {
+ RichText = richText;
+ }
+ public IXLRichText RichText { get; private set; }
+
+ public String HFText
+ {
+ get
+ {
+ String retVal = String.Empty;
+
+ retVal += RichText.FontName != null ? "&\"" + RichText.FontName : "\"-";
+ retVal += GetHFFontBoldItalic(RichText);
+ retVal += RichText.FontSize > 0 ? "&" + RichText.FontSize.ToString() : "";
+ retVal += RichText.Strikethrough ? "&S" : "";
+ retVal += RichText.VerticalAlignment == XLFontVerticalTextAlignmentValues.Subscript ? "&Y" : "";
+ retVal += RichText.VerticalAlignment == XLFontVerticalTextAlignmentValues.Superscript ? "&X" : "";
+ retVal += RichText.Underline == XLFontUnderlineValues.Single ? "&U" : "";
+ retVal += RichText.Underline == XLFontUnderlineValues.Double ? "&E" : "";
+ retVal += "&K" + RichText.FontColor.Color.ToHex().Substring(2);
+
+ retVal += RichText.Text;
+
+ retVal += RichText.Underline == XLFontUnderlineValues.Double ? "&E" : "";
+ retVal += RichText.Underline == XLFontUnderlineValues.Single ? "&U" : "";
+ retVal += RichText.VerticalAlignment == XLFontVerticalTextAlignmentValues.Superscript ? "&X" : "";
+ retVal += RichText.VerticalAlignment == XLFontVerticalTextAlignmentValues.Subscript ? "&Y" : "";
+ retVal += RichText.Strikethrough ? "&S" : "";
+
+ return retVal;
+ }
+ }
+
+ private String GetHFFontBoldItalic(IXLRichText xlFont)
+ {
+ String retVal = String.Empty;
+ if (xlFont.Bold && xlFont.Italic)
+ {
+ retVal += ",Bold Italic\"";
+ }
+ else if (xlFont.Bold)
+ {
+ retVal += ",Bold\"";
+ }
+ else if (xlFont.Italic)
+ {
+ retVal += ",Italic\"";
+ }
+ else
+ {
+ retVal += ",Regular\"";
+ }
+
+ return retVal;
+ }
+ }
+}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeBase.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeBase.cs
index e156d8f..f21b34e 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeBase.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeBase.cs
@@ -204,5 +204,7 @@
IXLCells FindCells(String search, XLSearchContents searchContents);
IXLCells FindCells(String search, XLSearchContents searchContents, Boolean useRegularExpressions);
IXLCells FindCells(String search, XLSearchContents searchContents, Boolean matchCase, Boolean entireCell);
+
+ IXLChart CreateChart(Int32 firstRow, Int32 firstColumn, Int32 lastRow, Int32 lastColumn);
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumn.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumn.cs
index 0aeaad4..6b6ff9c 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumn.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumn.cs
@@ -92,6 +92,8 @@
IXLRangeColumn Replace(String oldValue, String newValue);
IXLRangeColumn Replace(String oldValue, String newValue, XLSearchContents searchContents);
IXLRangeColumn Replace(String oldValue, String newValue, XLSearchContents searchContents, Boolean useRegularExpressions);
+
+ IXLRangeColumn Column(Int32 start, Int32 end);
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRow.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRow.cs
index 5c9a3e2..b864e68 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRow.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRow.cs
@@ -99,6 +99,8 @@
IXLRangeRow Replace(String oldValue, String newValue);
IXLRangeRow Replace(String oldValue, String newValue, XLSearchContents searchContents);
IXLRangeRow Replace(String oldValue, String newValue, XLSearchContents searchContents, Boolean useRegularExpressions);
+
+ IXLRangeRow Row(Int32 start, Int32 end);
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeBase.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeBase.cs
index 124539d..11804f6 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeBase.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeBase.cs
@@ -1067,5 +1067,16 @@
{
throw new NotImplementedException();
}
+
+ public IXLChart CreateChart(Int32 firstRow, Int32 firstColumn, Int32 lastRow, Int32 lastColumn)
+ {
+ IXLChart chart = new XLChart(Worksheet);
+ chart.FirstRow = firstRow;
+ chart.LastRow = lastRow;
+ chart.LastColumn = lastColumn;
+ chart.FirstColumn = firstColumn;
+ Worksheet.Charts.Add(chart);
+ return chart;
+ }
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeColumn.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeColumn.cs
index c62d0c8..b5c1ad6 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeColumn.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeColumn.cs
@@ -229,6 +229,11 @@
base.Replace(oldValue, newValue, searchContents, useRegularExpressions);
return this;
}
+
+ public IXLRangeColumn Column(Int32 start, Int32 end)
+ {
+ return Range(start, 1, end, 1).Column(1);
+ }
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeRow.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeRow.cs
index 52b9c2a..9d3563c 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeRow.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeRow.cs
@@ -242,6 +242,11 @@
base.Replace(oldValue, newValue, searchContents, useRegularExpressions);
return this;
}
+
+ public IXLRangeRow Row(Int32 start, Int32 end)
+ {
+ return Range(1, start, 1, end).Row(1);
+ }
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/RichText/IXLRichText.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/RichText/IXLRichText.cs
new file mode 100644
index 0000000..8bff436
--- /dev/null
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/RichText/IXLRichText.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ClosedXML.Excel
+{
+ public interface IXLRichText: IEquatable
+ {
+ String Text { get; }
+
+ 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; }
+ IXLColor FontColor { get; set; }
+ String FontName { get; set; }
+ XLFontFamilyNumberingValues FontFamilyNumbering { get; set; }
+
+ IXLRichText SetBold(); IXLRichText SetBold(Boolean value);
+ IXLRichText SetItalic(); IXLRichText SetItalic(Boolean value);
+ IXLRichText SetUnderline(); IXLRichText SetUnderline(XLFontUnderlineValues value);
+ IXLRichText SetStrikethrough(); IXLRichText SetStrikethrough(Boolean value);
+ IXLRichText SetVerticalAlignment(XLFontVerticalTextAlignmentValues value);
+ IXLRichText SetShadow(); IXLRichText SetShadow(Boolean value);
+ IXLRichText SetFontSize(Double value);
+ IXLRichText SetFontColor(IXLColor value);
+ IXLRichText SetFontName(String value);
+ IXLRichText SetFontFamilyNumbering(XLFontFamilyNumberingValues value);
+ }
+}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/RichText/XLRichText.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/RichText/XLRichText.cs
new file mode 100644
index 0000000..7ba0581
--- /dev/null
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/RichText/XLRichText.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ClosedXML.Excel
+{
+ internal class XLRichText: IXLRichText
+ {
+ public XLRichText(String text)
+ {
+ Text = text;
+
+ var defaultFont = XLWorkbook.DefaultStyle.Font;
+ 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 String Text { get; private set; }
+
+ public Boolean Bold { get; set; }
+ public Boolean Italic { get; set; }
+ public XLFontUnderlineValues Underline { get; set; }
+ public Boolean Strikethrough { get; set; }
+ public XLFontVerticalTextAlignmentValues VerticalAlignment { get; set; }
+ public Boolean Shadow { get; set; }
+ public Double FontSize { get; set; }
+ public IXLColor FontColor { get; set; }
+ public String FontName { get; set; }
+ public XLFontFamilyNumberingValues FontFamilyNumbering { get; set; }
+
+ public IXLRichText SetBold() { Bold = true; return this; } public IXLRichText SetBold(Boolean value) { Bold = value; return this; }
+ public IXLRichText SetItalic() { Italic = true; return this; } public IXLRichText SetItalic(Boolean value) { Italic = value; return this; }
+ public IXLRichText SetUnderline() { Underline = XLFontUnderlineValues.Single; return this; } public IXLRichText SetUnderline(XLFontUnderlineValues value) { Underline = value; return this; }
+ public IXLRichText SetStrikethrough() { Strikethrough = true; return this; } public IXLRichText SetStrikethrough(Boolean value) { Strikethrough = value; return this; }
+ public IXLRichText SetVerticalAlignment(XLFontVerticalTextAlignmentValues value) { VerticalAlignment = value; return this; }
+ public IXLRichText SetShadow() { Shadow = true; return this; } public IXLRichText SetShadow(Boolean value) { Shadow = value; return this; }
+ public IXLRichText SetFontSize(Double value) { FontSize = value; return this; }
+ public IXLRichText SetFontColor(IXLColor value) { FontColor = value; return this; }
+ public IXLRichText SetFontName(String value) { FontName = value; return this; }
+ public IXLRichText SetFontFamilyNumbering(XLFontFamilyNumberingValues value) { FontFamilyNumbering = value; return this; }
+
+ public Boolean Equals(IXLRichText other)
+ {
+ return
+ this.Bold.Equals(other.Bold)
+ && this.Italic.Equals(other.Italic)
+ && this.Underline.Equals(other.Underline)
+ && this.Strikethrough.Equals(other.Strikethrough)
+ && this.VerticalAlignment.Equals(other.VerticalAlignment)
+ && this.Shadow.Equals(other.Shadow)
+ && this.FontSize.Equals(other.FontSize)
+ && this.FontColor.Equals(other.FontColor)
+ && this.FontName.Equals(other.FontName)
+ && this.FontFamilyNumbering.Equals(other.FontFamilyNumbering)
+ ;
+ }
+
+ public override bool Equals(object obj)
+ {
+ return this.Equals((XLRichText)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Bold.GetHashCode()
+ ^ Italic.GetHashCode()
+ ^ (Int32)Underline
+ ^ Strikethrough.GetHashCode()
+ ^ (Int32)VerticalAlignment
+ ^ Shadow.GetHashCode()
+ ^ FontSize.GetHashCode()
+ ^ FontColor.GetHashCode()
+ ^ FontName.GetHashCode()
+ ^ (Int32)FontFamilyNumbering;
+ }
+ }
+}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/XLRow.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/XLRow.cs
index 8dd0417..e7aa62d 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/XLRow.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/XLRow.cs
@@ -579,7 +579,7 @@
public IXLRangeRow Row(Int32 start, Int32 end)
{
- return this.AsRange().Range(1, start, 1, end).Row(1);
+ return Range(1, start, 1, end).Row(1);
}
public new IXLRow Replace(String oldValue, String newValue)
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLFont.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLFont.cs
index 5e14140..397b502 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLFont.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Style/IXLFont.cs
@@ -56,6 +56,5 @@
IXLStyle SetFontName(String value);
IXLStyle SetFontFamilyNumbering(XLFontFamilyNumberingValues value);
-
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook.cs
index bad8610..f6838b1 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook.cs
@@ -331,10 +331,10 @@
Margins = new XLMargins()
{
Top = 0.75,
- Bottom = 0.75,
+ Bottom = 0.5,
Left = 0.75,
Right = 0.75,
- Header = 0.75,
+ Header = 0.5,
Footer = 0.75
},
ScaleHFWithDocument = true,
@@ -356,10 +356,6 @@
}
}
- public static IXLFont GetXLFont()
- {
- return new XLFont();
- }
#endregion
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Load.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Load.cs
index 5908f58..47520dc 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Load.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Load.cs
@@ -219,12 +219,11 @@
Int32 styleIndex = dCell.StyleIndex != null ? Int32.Parse(dCell.StyleIndex.InnerText) : 0;
var xlCell = (XLCell)ws.Cell(dCell.CellReference);
- //if (dCell.CellReference.Value == "A56")
+ //if (dCell.CellReference.Value == "A9")
// dCell.CellReference = dCell.CellReference.Value;
if (styleIndex > 0)
{
- //styleIndex = Int32.Parse(dCell.StyleIndex.InnerText);
ApplyStyle(xlCell, styleIndex, s, fills, borders, fonts, numberingFormats);
}
else
@@ -303,8 +302,7 @@
}
else if (dCell.CellValue != null)
{
- //var styleIndex = Int32.Parse(dCell.StyleIndex.InnerText);
- var numberFormatId = ((CellFormat)((CellFormats)s.CellFormats).ElementAt(styleIndex)).NumberFormatId; //. [styleIndex].NumberFormatId;
+ var numberFormatId = ((CellFormat)((CellFormats)s.CellFormats).ElementAt(styleIndex)).NumberFormatId;
Double val = Double.Parse(dCell.CellValue.Text, CultureInfo.InvariantCulture);
xlCell.Value = val;
if (s.NumberingFormats != null && s.NumberingFormats.Where(nf => ((NumberingFormat)nf).NumberFormatId.Value == numberFormatId).Any())
@@ -323,29 +321,6 @@
xlCell.DataType = XLCellValues.Text;
else
xlCell.DataType = XLCellValues.Number;
-
-
- //if (val >= 0 && val <= DateTimeExtensions.MaxOADate)
- //{
- // xlCell.DataType = GetDataTypeFromFormat(xlCell.Style.NumberFormat.Format);
- // //String format = xlCell.Style.NumberFormat.Format.EndsWith(";@") ? xlCell.Style.NumberFormat.Format.Substring(0, xlCell.Style.NumberFormat.Format.Length - 2) : xlCell.Style.NumberFormat.Format;
-
- // //Double dTest;
- // //if (!Double.TryParse(val.ToString(format), out dTest))
- // // xlCell.DataType = XLCellValues.DateTime;
-
- // //String format = xlCell.Style.NumberFormat.Format.EndsWith(";@") ? xlCell.Style.NumberFormat.Format.Substring(0, xlCell.Style.NumberFormat.Format.Length - 2) : xlCell.Style.NumberFormat.Format;
- // //format = FixFormatForDates(format);
- // ////Double dTest;
- // ////if (!Double.TryParse(val.ToString(format) , out dTest))
- // //DateTime dTest;
- // //if (DateTime.TryParseExact(DateTime.FromOADate(val).ToString(format), format, CultureInfo.InvariantCulture, DateTimeStyles.None , out dTest))
- // // xlCell.DataType = XLCellValues.DateTime;
-
- // ////if (DateTime.TryParse(val.ToString(format), out dTest))
- // //if ((numberFormatId >= 14 && numberFormatId <= 22) || (numberFormatId >= 165 && numberFormatId <= 180))
- // // xlCell.DataType = XLCellValues.DateTime;
- //}
}
}
#endregion
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs
index c45b33e..1d56301 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs
@@ -66,7 +66,7 @@
}
}
- private enum RelType { General, Workbook, Worksheet }
+ private enum RelType { General, Workbook, Worksheet, Drawing }
private class RelIdGenerator
{
private Dictionary> relIds = new Dictionary>();
@@ -417,11 +417,16 @@
worksheetPart = workbookPart.AddNewPart(worksheet.RelId);
}
-
GenerateWorksheetPartContent(worksheetPart, worksheet);
- //DrawingsPart drawingsPart = worksheetPart.AddNewPart(relId.GetNext(RelType.Workbook));
- //GenerateDrawingsPartContent(drawingsPart);
+ //DrawingsPart drawingsPart = worksheetPart.AddNewPart("rId1");
+ //GenerateDrawingsPartContent(drawingsPart, worksheet);
+
+ //foreach (var chart in worksheet.Charts)
+ //{
+ // ChartPart chartPart = drawingsPart.AddNewPart("rId1");
+ // GenerateChartPartContent(chartPart, (XLChart)chart);
+ //}
}
@@ -1494,7 +1499,7 @@
private bool FontsAreEqual(Font f, IXLFont xlFont)
{
- var nf = XLWorkbook.GetXLFont();
+ var nf = new XLFont();
nf.Bold = f.Bold != null;
nf.Italic = f.Italic != null;
if (f.Underline != null)
@@ -1602,7 +1607,6 @@
#endregion
-
UInt32 maxColumn = 0;
UInt32 maxRow = 0;
@@ -2420,6 +2424,17 @@
}
#endregion
+ #region Drawings
+ //worksheetPart.Worksheet.RemoveAllChildren();
+ //{
+ // OpenXmlElement previousElement = cm.GetPreviousElementFor(XLWSContentManager.XLWSContents.Drawing);
+ // worksheetPart.Worksheet.InsertAfter(new Drawing() { Id = String.Format("rId{0}", 1) }, previousElement);
+ //}
+
+ //Drawing drawing = worksheetPart.Worksheet.Elements().First();
+ //cm.SetElement(XLWSContentManager.XLWSContents.Drawing, drawing);
+ #endregion
+
#region Tables
worksheetPart.Worksheet.RemoveAllChildren();
{
@@ -3352,101 +3367,378 @@
tableDefinitionPart.Table = table;
}
- /*
- // Generates content of drawingsPart1.
- private void GenerateDrawingsPartContent(DrawingsPart drawingsPart, XLWorksheet worksheet)
- {
- if (drawingsPart.WorksheetDrawing == null)
- drawingsPart.WorksheetDrawing = new Xdr.WorksheetDrawing();
+ //private void GenerateDrawingsPartContent(DrawingsPart drawingsPart, XLWorksheet worksheet)
+ //{
+ // if (drawingsPart.WorksheetDrawing == null)
+ // drawingsPart.WorksheetDrawing = new Xdr.WorksheetDrawing();
- var worksheetDrawing = drawingsPart.WorksheetDrawing;
+ // var worksheetDrawing = drawingsPart.WorksheetDrawing;
- if (!worksheetDrawing.NamespaceDeclarations.Contains(new KeyValuePair("xdr", "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing")))
- worksheetDrawing.AddNamespaceDeclaration("xdr", "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
- if (!worksheetDrawing.NamespaceDeclarations.Contains(new KeyValuePair("a", "http://schemas.openxmlformats.org/drawingml/2006/main")))
- worksheetDrawing.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
-
- foreach (var chart in worksheet.Charts.OrderBy(c=>c.Position.ZOrder).Select(c=>c))
- {
- Xdr.TwoCellAnchor twoCellAnchor = new Xdr.TwoCellAnchor();
- twoCellAnchor.
- }
+ // if (!worksheetDrawing.NamespaceDeclarations.Contains(new KeyValuePair("xdr", "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing")))
+ // worksheetDrawing.AddNamespaceDeclaration("xdr", "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
+ // if (!worksheetDrawing.NamespaceDeclarations.Contains(new KeyValuePair("a", "http://schemas.openxmlformats.org/drawingml/2006/main")))
+ // worksheetDrawing.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
+ // foreach (var chart in worksheet.Charts.OrderBy(c=>c.ZOrder).Select(c=>c))
+ // {
+ // Xdr.TwoCellAnchor twoCellAnchor = new Xdr.TwoCellAnchor();
+ // worksheetDrawing.Append(twoCellAnchor);
+ // if (chart.Anchor == XLDrawingAnchor.MoveAndSizeWithCells)
+ // twoCellAnchor.EditAs = Xdr.EditAsValues.TwoCell;
+ // else if (chart.Anchor == XLDrawingAnchor.MoveWithCells)
+ // twoCellAnchor.EditAs = Xdr.EditAsValues.OneCell;
+ // else
+ // twoCellAnchor.EditAs = Xdr.EditAsValues.Absolute;
- Xdr.FromMarker fromMarker1 = new Xdr.FromMarker();
- Xdr.ColumnId columnId1 = new Xdr.ColumnId();
- columnId1.Text = "3";
- Xdr.ColumnOffset columnOffset1 = new Xdr.ColumnOffset();
- columnOffset1.Text = "152400";
- Xdr.RowId rowId1 = new Xdr.RowId();
- rowId1.Text = "0";
- Xdr.RowOffset rowOffset1 = new Xdr.RowOffset();
- rowOffset1.Text = "133350";
+ // if (twoCellAnchor.FromMarker == null)
+ // twoCellAnchor.FromMarker = new Xdr.FromMarker();
+ // twoCellAnchor.FromMarker.RowId = new Xdr.RowId((chart.FirstRow - 1).ToString());
+ // twoCellAnchor.FromMarker.RowOffset = new Xdr.RowOffset(chart.FirstRowOffset.ToString());
+ // twoCellAnchor.FromMarker.ColumnId = new Xdr.ColumnId((chart.FirstColumn - 1).ToString());
+ // twoCellAnchor.FromMarker.ColumnOffset = new Xdr.ColumnOffset(chart.FirstColumnOffset.ToString());
- fromMarker1.Append(columnId1);
- fromMarker1.Append(columnOffset1);
- fromMarker1.Append(rowId1);
- fromMarker1.Append(rowOffset1);
+ // if (twoCellAnchor.ToMarker == null)
+ // twoCellAnchor.ToMarker = new Xdr.ToMarker();
+ // twoCellAnchor.ToMarker.RowId = new Xdr.RowId((chart.LastRow - 1).ToString());
+ // twoCellAnchor.ToMarker.RowOffset = new Xdr.RowOffset(chart.LastRowOffset.ToString());
+ // twoCellAnchor.ToMarker.ColumnId = new Xdr.ColumnId((chart.LastColumn - 1).ToString());
+ // twoCellAnchor.ToMarker.ColumnOffset = new Xdr.ColumnOffset(chart.LastColumnOffset.ToString());
- Xdr.ToMarker toMarker1 = new Xdr.ToMarker();
- Xdr.ColumnId columnId2 = new Xdr.ColumnId();
- columnId2.Text = "10";
- Xdr.ColumnOffset columnOffset2 = new Xdr.ColumnOffset();
- columnOffset2.Text = "457200";
- Xdr.RowId rowId2 = new Xdr.RowId();
- rowId2.Text = "15";
- Xdr.RowOffset rowOffset2 = new Xdr.RowOffset();
- rowOffset2.Text = "19050";
- toMarker1.Append(columnId2);
- toMarker1.Append(columnOffset2);
- toMarker1.Append(rowId2);
- toMarker1.Append(rowOffset2);
- Xdr.GraphicFrame graphicFrame1 = new Xdr.GraphicFrame() { Macro = "" };
+ // Xdr.GraphicFrame graphicFrame = new Xdr.GraphicFrame();
+ // twoCellAnchor.Append(graphicFrame);
- Xdr.NonVisualGraphicFrameProperties nonVisualGraphicFrameProperties1 = new Xdr.NonVisualGraphicFrameProperties();
- Xdr.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Xdr.NonVisualDrawingProperties() { Id = (UInt32Value)5U, Name = "Chart 4" };
- Xdr.NonVisualGraphicFrameDrawingProperties nonVisualGraphicFrameDrawingProperties1 = new Xdr.NonVisualGraphicFrameDrawingProperties();
+ // if (graphicFrame.NonVisualGraphicFrameProperties == null)
+ // graphicFrame.NonVisualGraphicFrameProperties = new Xdr.NonVisualGraphicFrameProperties();
- nonVisualGraphicFrameProperties1.Append(nonVisualDrawingProperties1);
- nonVisualGraphicFrameProperties1.Append(nonVisualGraphicFrameDrawingProperties1);
+ // if (graphicFrame.NonVisualGraphicFrameProperties.NonVisualDrawingProperties == null)
+ // graphicFrame.NonVisualGraphicFrameProperties.NonVisualDrawingProperties = new Xdr.NonVisualDrawingProperties() { Id = (UInt32)chart.Id, Name = chart.Name, Description = chart.Description, Hidden = chart.Hidden };
+ // if (graphicFrame.NonVisualGraphicFrameProperties.NonVisualGraphicFrameDrawingProperties == null)
+ // graphicFrame.NonVisualGraphicFrameProperties.NonVisualGraphicFrameDrawingProperties = new Xdr.NonVisualGraphicFrameDrawingProperties();
- Xdr.Transform transform1 = new Xdr.Transform();
- A.Offset offset1 = new A.Offset() { X = 0L, Y = 0L };
- A.Extents extents1 = new A.Extents() { Cx = 0L, Cy = 0L };
+ // if (graphicFrame.Transform == null)
+ // graphicFrame.Transform = new Xdr.Transform();
- transform1.Append(offset1);
- transform1.Append(extents1);
+ // if (chart.HorizontalFlip)
+ // graphicFrame.Transform.HorizontalFlip = true;
+ // else
+ // graphicFrame.Transform.HorizontalFlip = null;
- A.Graphic graphic1 = new A.Graphic();
+ // if (chart.VerticalFlip)
+ // graphicFrame.Transform.VerticalFlip = true;
+ // else
+ // graphicFrame.Transform.VerticalFlip = null;
- A.GraphicData graphicData1 = new A.GraphicData() { Uri = "http://schemas.openxmlformats.org/drawingml/2006/chart" };
+ // if (chart.Rotation != 0)
+ // graphicFrame.Transform.Rotation = chart.Rotation;
+ // else
+ // graphicFrame.Transform.Rotation = null;
- C.ChartReference chartReference1 = new C.ChartReference() { Id = "rId1" };
- chartReference1.AddNamespaceDeclaration("c", "http://schemas.openxmlformats.org/drawingml/2006/chart");
- chartReference1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
+ // if (graphicFrame.Transform.Offset == null)
+ // graphicFrame.Transform.Offset = new A.Offset();
- graphicData1.Append(chartReference1);
+ // graphicFrame.Transform.Offset.X = chart.OffsetX;
+ // graphicFrame.Transform.Offset.Y = chart.OffsetY;
- graphic1.Append(graphicData1);
+ // if (graphicFrame.Transform.Extents == null)
+ // graphicFrame.Transform.Extents = new A.Extents();
- graphicFrame1.Append(nonVisualGraphicFrameProperties1);
- graphicFrame1.Append(transform1);
- graphicFrame1.Append(graphic1);
- Xdr.ClientData clientData1 = new Xdr.ClientData();
+ // graphicFrame.Transform.Extents.Cx = chart.ExtentLength;
+ // graphicFrame.Transform.Extents.Cy = chart.ExtentWidth;
- twoCellAnchor1.Append(fromMarker1);
- twoCellAnchor1.Append(toMarker1);
- twoCellAnchor1.Append(graphicFrame1);
- twoCellAnchor1.Append(clientData1);
+ // if (graphicFrame.Graphic == null)
+ // graphicFrame.Graphic = new A.Graphic();
- worksheetDrawing1.Append(twoCellAnchor1);
+ // if (graphicFrame.Graphic.GraphicData == null)
+ // graphicFrame.Graphic.GraphicData = new A.GraphicData() { Uri = "http://schemas.openxmlformats.org/drawingml/2006/chart" };
- drawingsPart1.WorksheetDrawing = worksheetDrawing1;
+ // if (!graphicFrame.Graphic.GraphicData.Elements().Any())
+ // {
+ // C.ChartReference chartReference = new C.ChartReference() { Id = "rId" + chart.Id.ToStringLookup() };
+ // chartReference.AddNamespaceDeclaration("c", "http://schemas.openxmlformats.org/drawingml/2006/chart");
+ // chartReference.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
- }
- */
+ // graphicFrame.Graphic.GraphicData.Append(chartReference);
+ // }
+
+ // if (!twoCellAnchor.Elements().Any())
+ // twoCellAnchor.Append(new Xdr.ClientData());
+ // }
+ //}
+
+ //private void GenerateChartPartContent(ChartPart chartPart, XLChart xlChart)
+ //{
+ // if (chartPart.ChartSpace == null)
+ // chartPart.ChartSpace = new C.ChartSpace();
+
+ // C.ChartSpace chartSpace = chartPart.ChartSpace;
+
+ // if (!chartSpace.NamespaceDeclarations.Contains(new KeyValuePair("c", "http://schemas.openxmlformats.org/drawingml/2006/chart")))
+ // chartSpace.AddNamespaceDeclaration("c", "http://schemas.openxmlformats.org/drawingml/2006/chart");
+ // if (!chartSpace.NamespaceDeclarations.Contains(new KeyValuePair("a", "http://schemas.openxmlformats.org/drawingml/2006/main")))
+ // chartSpace.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
+ // if (!chartSpace.NamespaceDeclarations.Contains(new KeyValuePair("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships")))
+ // chartSpace.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
+
+ // if (chartSpace.EditingLanguage == null)
+ // chartSpace.EditingLanguage = new C.EditingLanguage() { Val = CultureInfo.CurrentCulture.Name };
+ // else
+ // chartSpace.EditingLanguage.Val = CultureInfo.CurrentCulture.Name;
+
+ // C.Chart chart = new C.Chart();
+ // chartSpace.Append(chart);
+
+ // if (chart.Title == null)
+ // chart.Title = new C.Title();
+
+ // if (chart.Title.Layout == null)
+ // chart.Title.Layout = new C.Layout();
+
+ // if (chart.View3D == null)
+ // chart.View3D = new C.View3D();
+
+ // if (chart.View3D.RightAngleAxes == null)
+ // chart.View3D.RightAngleAxes = new C.RightAngleAxes();
+
+ // chart.View3D.RightAngleAxes.Val = xlChart.RightAngleAxes;
+
+ // if (chart.PlotArea == null)
+ // chart.PlotArea = new C.PlotArea();
+
+ // if (chart.PlotArea.Layout == null)
+ // chart.PlotArea.Layout = new C.Layout();
+
+ // OpenXmlElement chartElement = GetChartElement(xlChart);
+
+ // chart.PlotArea.Append(chartElement);
+
+
+
+ // C.CategoryAxis categoryAxis1 = new C.CategoryAxis();
+ // C.AxisId axisId4 = new C.AxisId() { Val = (UInt32Value)71429120U };
+
+ // C.Scaling scaling1 = new C.Scaling();
+ // C.Orientation orientation1 = new C.Orientation() { Val = C.OrientationValues.MinMax };
+
+ // scaling1.Append(orientation1);
+ // C.AxisPosition axisPosition1 = new C.AxisPosition() { Val = C.AxisPositionValues.Bottom };
+ // C.TickLabelPosition tickLabelPosition1 = new C.TickLabelPosition() { Val = C.TickLabelPositionValues.NextTo };
+ // C.CrossingAxis crossingAxis1 = new C.CrossingAxis() { Val = (UInt32Value)71432064U };
+ // C.Crosses crosses1 = new C.Crosses() { Val = C.CrossesValues.AutoZero };
+ // C.AutoLabeled autoLabeled1 = new C.AutoLabeled() { Val = true };
+ // C.LabelAlignment labelAlignment1 = new C.LabelAlignment() { Val = C.LabelAlignmentValues.Center };
+ // C.LabelOffset labelOffset1 = new C.LabelOffset() { Val = (UInt16Value)100U };
+
+ // categoryAxis1.Append(axisId4);
+ // categoryAxis1.Append(scaling1);
+ // categoryAxis1.Append(axisPosition1);
+ // categoryAxis1.Append(tickLabelPosition1);
+ // categoryAxis1.Append(crossingAxis1);
+ // categoryAxis1.Append(crosses1);
+ // categoryAxis1.Append(autoLabeled1);
+ // categoryAxis1.Append(labelAlignment1);
+ // categoryAxis1.Append(labelOffset1);
+
+ // C.ValueAxis valueAxis1 = new C.ValueAxis();
+ // C.AxisId axisId5 = new C.AxisId() { Val = (UInt32Value)71432064U };
+
+ // C.Scaling scaling2 = new C.Scaling();
+ // C.Orientation orientation2 = new C.Orientation() { Val = C.OrientationValues.MinMax };
+
+ // scaling2.Append(orientation2);
+ // C.AxisPosition axisPosition2 = new C.AxisPosition() { Val = C.AxisPositionValues.Left };
+ // C.MajorGridlines majorGridlines1 = new C.MajorGridlines();
+ // C.NumberingFormat numberingFormat1 = new C.NumberingFormat() { FormatCode = "General", SourceLinked = true };
+ // C.TickLabelPosition tickLabelPosition2 = new C.TickLabelPosition() { Val = C.TickLabelPositionValues.NextTo };
+ // C.CrossingAxis crossingAxis2 = new C.CrossingAxis() { Val = (UInt32Value)71429120U };
+ // C.Crosses crosses2 = new C.Crosses() { Val = C.CrossesValues.AutoZero };
+ // C.CrossBetween crossBetween1 = new C.CrossBetween() { Val = C.CrossBetweenValues.Between };
+
+ // valueAxis1.Append(axisId5);
+ // valueAxis1.Append(scaling2);
+ // valueAxis1.Append(axisPosition2);
+ // valueAxis1.Append(majorGridlines1);
+ // valueAxis1.Append(numberingFormat1);
+ // valueAxis1.Append(tickLabelPosition2);
+ // valueAxis1.Append(crossingAxis2);
+ // valueAxis1.Append(crosses2);
+ // valueAxis1.Append(crossBetween1);
+
+
+ // plotArea.Append(bar3DChart1);
+ // plotArea.Append(categoryAxis1);
+ // plotArea.Append(valueAxis1);
+
+ // C.Legend legend1 = new C.Legend();
+ // C.LegendPosition legendPosition1 = new C.LegendPosition() { Val = C.LegendPositionValues.Right };
+ // C.Layout layout3 = new C.Layout();
+
+ // legend1.Append(legendPosition1);
+ // legend1.Append(layout3);
+ // C.PlotVisibleOnly plotVisibleOnly1 = new C.PlotVisibleOnly() { Val = true };
+
+
+
+ // chart.Append(legend1);
+ // chart.Append(plotVisibleOnly1);
+
+ // C.PrintSettings printSettings1 = new C.PrintSettings();
+ // C.HeaderFooter headerFooter1 = new C.HeaderFooter();
+ // C.PageMargins pageMargins4 = new C.PageMargins() { Left = 0.70000000000000018D, Right = 0.70000000000000018D, Top = 0.75000000000000022D, Bottom = 0.75000000000000022D, Header = 0.3000000000000001D, Footer = 0.3000000000000001D };
+ // C.PageSetup pageSetup1 = new C.PageSetup();
+
+ // printSettings1.Append(headerFooter1);
+ // printSettings1.Append(pageMargins4);
+ // printSettings1.Append(pageSetup1);
+
+
+
+ // chartSpace.Append(printSettings1);
+
+ //}
+
+ //private OpenXmlElement GetChartElement(XLChart xlChart)
+ //{
+ // if (xlChart.ChartTypeCategory == XLChartTypeCategory.Bar3D)
+ // return GetBar3DChart(xlChart);
+ // else
+ // return null;
+ //}
+
+ //private OpenXmlElement GetBar3DChart(XLChart xlChart)
+ //{
+
+ // C.Bar3DChart bar3DChart = new C.Bar3DChart();
+ // bar3DChart.BarDirection = new C.BarDirection() { Val = GetBarDirection(xlChart) };
+ // bar3DChart.BarGrouping = new C.BarGrouping() { Val = GetBarGrouping(xlChart) };
+
+ // C.BarChartSeries barChartSeries = new C.BarChartSeries();
+ // barChartSeries.Index = new C.Index() { Val = (UInt32Value)0U };
+ // barChartSeries.Order = new C.Order() { Val = (UInt32Value)0U };
+
+ // C.SeriesText seriesText1 = new C.SeriesText();
+
+ // C.StringReference stringReference1 = new C.StringReference();
+ // C.Formula formula1 = new C.Formula();
+ // formula1.Text = "Sheet1!$B$1";
+ // C.StringCache stringCache1 = new C.StringCache();
+ // C.PointCount pointCount1 = new C.PointCount() { Val = (UInt32Value)1U };
+ // C.StringPoint stringPoint1 = new C.StringPoint() { Index = (UInt32Value)0U };
+ // C.NumericValue numericValue1 = new C.NumericValue();
+ // numericValue1.Text = "Value";
+
+ // stringPoint1.Append(numericValue1);
+ // stringCache1.Append(pointCount1);
+ // stringCache1.Append(stringPoint1);
+ // stringReference1.Append(formula1);
+ // stringReference1.Append(stringCache1);
+ // seriesText1.Append(stringReference1);
+
+ // C.CategoryAxisData categoryAxisData1 = new C.CategoryAxisData();
+
+ // C.StringReference stringReference2 = new C.StringReference();
+ // C.Formula formula2 = new C.Formula();
+ // formula2.Text = "Sheet1!$A$2:$A$3";
+
+ // C.StringCache stringCache2 = new C.StringCache();
+ // C.PointCount pointCount2 = new C.PointCount() { Val = (UInt32Value)2U };
+
+ // C.StringPoint stringPoint2 = new C.StringPoint() { Index = (UInt32Value)0U };
+ // C.NumericValue numericValue2 = new C.NumericValue();
+ // numericValue2.Text = "A";
+
+ // stringPoint2.Append(numericValue2);
+
+ // C.StringPoint stringPoint3 = new C.StringPoint() { Index = (UInt32Value)1U };
+ // C.NumericValue numericValue3 = new C.NumericValue();
+ // numericValue3.Text = "B";
+
+ // stringPoint3.Append(numericValue3);
+
+ // stringCache2.Append(pointCount2);
+ // stringCache2.Append(stringPoint2);
+ // stringCache2.Append(stringPoint3);
+
+ // stringReference2.Append(formula2);
+ // stringReference2.Append(stringCache2);
+
+ // categoryAxisData1.Append(stringReference2);
+
+ // C.Values values1 = new C.Values();
+
+ // C.NumberReference numberReference1 = new C.NumberReference();
+ // C.Formula formula3 = new C.Formula();
+ // formula3.Text = "Sheet1!$B$2:$B$3";
+
+ // C.NumberingCache numberingCache1 = new C.NumberingCache();
+ // C.FormatCode formatCode1 = new C.FormatCode();
+ // formatCode1.Text = "General";
+ // C.PointCount pointCount3 = new C.PointCount() { Val = (UInt32Value)2U };
+
+ // C.NumericPoint numericPoint1 = new C.NumericPoint() { Index = (UInt32Value)0U };
+ // C.NumericValue numericValue4 = new C.NumericValue();
+ // numericValue4.Text = "5";
+
+ // numericPoint1.Append(numericValue4);
+
+ // C.NumericPoint numericPoint2 = new C.NumericPoint() { Index = (UInt32Value)1U };
+ // C.NumericValue numericValue5 = new C.NumericValue();
+ // numericValue5.Text = "10";
+
+ // numericPoint2.Append(numericValue5);
+
+ // numberingCache1.Append(formatCode1);
+ // numberingCache1.Append(pointCount3);
+ // numberingCache1.Append(numericPoint1);
+ // numberingCache1.Append(numericPoint2);
+
+ // numberReference1.Append(formula3);
+ // numberReference1.Append(numberingCache1);
+
+ // values1.Append(numberReference1);
+
+ // barChartSeries.Append(index1);
+ // barChartSeries.Append(order1);
+ // barChartSeries.Append(seriesText1);
+ // barChartSeries.Append(categoryAxisData1);
+ // barChartSeries.Append(values1);
+ // C.Shape shape1 = new C.Shape() { Val = C.ShapeValues.Box };
+ // C.AxisId axisId1 = new C.AxisId() { Val = (UInt32Value)71429120U };
+ // C.AxisId axisId2 = new C.AxisId() { Val = (UInt32Value)71432064U };
+ // C.AxisId axisId3 = new C.AxisId() { Val = (UInt32Value)0U };
+
+
+ // bar3DChart.Append(barChartSeries);
+ // bar3DChart.Append(shape1);
+ // bar3DChart.Append(axisId1);
+ // bar3DChart.Append(axisId2);
+ // bar3DChart.Append(axisId3);
+
+ // return bar3DChart;
+ //}
+
+ //private C.BarGroupingValues GetBarGrouping(XLChart xlChart)
+ //{
+ // if (xlChart.BarGrouping == XLBarGrouping.Clustered)
+ // return C.BarGroupingValues.Clustered;
+ // else if (xlChart.BarGrouping == XLBarGrouping.Percent)
+ // return C.BarGroupingValues.PercentStacked;
+ // else if (xlChart.BarGrouping == XLBarGrouping.Stacked)
+ // return C.BarGroupingValues.Stacked;
+ // else
+ // return C.BarGroupingValues.Standard;
+ //}
+
+ //private C.BarDirectionValues GetBarDirection(XLChart xlChart)
+ //{
+ // if (xlChart.BarOrientation == XLBarOrientation.Vertical)
+ // return C.BarDirectionValues.Column;
+ // else
+ // return C.BarDirectionValues.Bar;
+ //}
+
+
}
}
\ No newline at end of file
diff --git a/ClosedXML/ClosedXML/ClosedXML_Examples/PageSetup/HeaderFooters.cs b/ClosedXML/ClosedXML/ClosedXML_Examples/PageSetup/HeaderFooters.cs
index db83726..d8b3798 100644
--- a/ClosedXML/ClosedXML/ClosedXML_Examples/PageSetup/HeaderFooters.cs
+++ b/ClosedXML/ClosedXML/ClosedXML_Examples/PageSetup/HeaderFooters.cs
@@ -21,22 +21,24 @@
// Simple left header to be placed on all pages
ws.PageSetup.Header.Left.AddText("Created with ClosedXML");
- // Using various fonts for the right header on the first page only
- var font1 = XLWorkbook.GetXLFont();
- font1.Bold = true;
- ws.PageSetup.Header.Right.AddText("The ", XLHFOccurrence.FirstPage, font1);
+ // Using various font decorations for the right header on the first page only
+ // Here we show different methods for setting font decorations.
+
+ // Set single font decorations immediately
+ ws.PageSetup.Header.Right.AddText("The ", XLHFOccurrence.FirstPage).SetBold();
+ ws.PageSetup.Header.Right.AddText("First ", XLHFOccurrence.FirstPage).SetFontColor(XLColor.Red);
- var font2 = XLWorkbook.GetXLFont();
- font2.FontColor = XLColor.Red;
- ws.PageSetup.Header.Right.AddText("First ", XLHFOccurrence.FirstPage, font2);
+ // Use the IXLRichText returned by the AddText(...) method to later on modify the font
+ var richText = ws.PageSetup.Header.Right.AddText("Colorful ", XLHFOccurrence.FirstPage);
+ richText.FontColor = XLColor.Blue;
+ richText.Underline = XLFontUnderlineValues.Double;
- var font3 = XLWorkbook.GetXLFont();
- font3.Underline = XLFontUnderlineValues.Double;
- ws.PageSetup.Header.Right.AddText("Colorful ", XLHFOccurrence.FirstPage, font3);
+ // Set multiple font decorations chained
+ ws.PageSetup.Header.Right.AddText("Page", XLHFOccurrence.FirstPage)
+ .SetBold()
+ .SetItalic()
+ .SetFontName("Broadway");
- var font4 = XLWorkbook.GetXLFont();
- font4.FontName = "Broadway";
- ws.PageSetup.Header.Right.AddText("Page", XLHFOccurrence.FirstPage, font4);
// Using predefined header/footer text:
diff --git a/ClosedXML/ClosedXML/ClosedXML_Net3.5/ClosedXML_Net3.5.csproj b/ClosedXML/ClosedXML/ClosedXML_Net3.5/ClosedXML_Net3.5.csproj
index 853c47e..05d4b19 100644
--- a/ClosedXML/ClosedXML/ClosedXML_Net3.5/ClosedXML_Net3.5.csproj
+++ b/ClosedXML/ClosedXML/ClosedXML_Net3.5/ClosedXML_Net3.5.csproj
@@ -136,8 +136,8 @@
Excel\Charts\IXLCharts.cs
-
- Excel\Charts\IXLDrawingPosition.cs
+
+ Excel\Charts\IXLDrawing.cs
Excel\Charts\XLChart.cs
@@ -145,8 +145,8 @@
Excel\Charts\XLCharts.cs
-
- Excel\Charts\XLDrawingPosition.cs
+
+ Excel\Charts\XLDrawing.cs
Excel\Columns\IXLColumn.cs
@@ -280,6 +280,9 @@
Excel\PageSetup\XLHFItem.cs
+
+ Excel\PageSetup\XLHFText.cs
+
Excel\PageSetup\XLMargins.cs
@@ -352,6 +355,12 @@
Excel\Ranges\XLRanges.cs
+
+ Excel\RichText\IXLRichText.cs
+
+
+ Excel\RichText\XLRichText.cs
+
Excel\Rows\IXLRow.cs
diff --git a/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs b/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs
index efc4cc8..261a8cb 100644
--- a/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs
+++ b/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs
@@ -16,7 +16,7 @@
{
//var fileName = "BasicTable";
//var fileName = "Sandbox";
- var fileName = "Issue_6510";
+ var fileName = "Issue_6609";
var wb = new XLWorkbook(String.Format(@"c:\Excel Files\ForTesting\{0}.xlsx", fileName));
//var wb = new XLWorkbook();
//var ws = wb.Worksheets.Add("Sheet1");
@@ -27,6 +27,13 @@
//ws.Cell("B2").Value = 5;
//ws.Cell("B3").Value = 10;
+ //ws.RangeUsed().CreateChart(4, 4, 22, 12);
+
+
+
+ var ws = wb.Worksheet(1);
+ String a = ws.Cell("A9").GetValue();
+
wb.SaveAs(String.Format(@"c:\Excel Files\ForTesting\{0}_Saved.xlsx", fileName));
//Console.ReadKey();
}