private static ExcelLineChart AddLine(ExcelWorksheet ws, eLineChartType type, string name, int row, int col) { var chart = ws.Drawings.AddLineChart(name, type); chart.SetPosition(row, 0, col, 0); chart.To.Column = col + 12; chart.To.ColumnOff = 0; chart.To.Row = row + 18; chart.To.RowOff = 0; chart.Series.Add("D2:D50", "A2:A50"); return(chart); }
private static void StyleLine3dChart(ExcelWorksheet ws, eLineChartType chartType) { //Style 1 AddLine3D(ws, chartType, "Line3dChartStyle1", 0, 5, ePresetChartStyle.Line3dChartStyle1, c => { c.Legend.Position = eLegendPosition.Bottom; c.Axis[0].MajorTickMark = eAxisTickMark.None; c.Axis[0].MinorTickMark = eAxisTickMark.None; c.Axis[1].MajorTickMark = eAxisTickMark.None; c.Axis[1].MinorTickMark = eAxisTickMark.None; }); //Style 2 AddLine(ws, chartType, "Line3dChartStyle2", 0, 18, ePresetChartStyle.Line3dChartStyle2, c => { c.Legend.Position = eLegendPosition.Bottom; c.YAxis.Deleted = true; c.Axis[0].MajorTickMark = eAxisTickMark.None; c.Axis[0].MinorTickMark = eAxisTickMark.None; c.Axis[1].MajorTickMark = eAxisTickMark.None; c.Axis[1].MinorTickMark = eAxisTickMark.None; if (chartType != eLineChartType.Line3D) { c.Marker = true; } c.DataLabel.ShowValue = true; //foreach (var serie in c.Series) //{ // if (chartType != eLineChartType.Line3D) // { // serie.Marker.Style = eMarkerStyle.Circle; // serie.Marker.Size = 17; // } // serie.DataLabel.Position = eLabelPosition.Center; // serie.DataLabel.ShowValue = true; //} }); //Style 3 AddLine(ws, chartType, "ColumnChartStyle3", 0, 31, ePresetChartStyle.Line3dChartStyle3, c => { }); //Style 4 AddLine(ws, chartType, "ColumnChartStyle4", 22, 5, ePresetChartStyle.Line3dChartStyle4, c => { }); }
private static ExcelLineChart AddLine3D(ExcelWorksheet ws, eLineChartType type, string name, int row, int col, ePresetChartStyle style, Action <ExcelLineChart> SetProperties) { var chart = ws.Drawings.AddLineChart(name, type); chart.SetPosition(row, 0, col, 0); chart.To.Column = col + 12; chart.To.ColumnOff = 0; chart.To.Row = row + 18; chart.To.RowOff = 0; var serie = chart.Series.Add("D2:D50", "A2:A50"); SetProperties(chart); chart.StyleManager.SetChartStyle(style); return(chart); }
/// <summary> /// Adds a new column- or bar- chart to the worksheet. /// </summary> /// <param name="Name"></param> /// <param name="ChartType">Type of chart</param> /// <param name="PivotTableSource">The pivottable source for a pivotchart</param> /// <returns>The chart</returns> public ExcelBarChart AddBarChart(string Name, eLineChartType ChartType, ExcelPivotTable PivotTableSource) { return((ExcelBarChart)AddChart(Name, (eChartType)ChartType, PivotTableSource)); }
/// <summary> /// Add a new linechart to the worksheet. /// </summary> /// <param name="Name"></param> /// <param name="ChartType">Type of linechart</param> /// <returns>The chart</returns> public ExcelLineChart AddLineChart(string Name, eLineChartType ChartType) { return((ExcelLineChart)AddChart(Name, (eChartType)ChartType, null)); }
private static void StyleLineChart(ExcelWorksheet ws, eLineChartType chartType) { //Style 1 AddLine(ws, chartType, "ColumnChartStyle1", 0, 5, ePresetChartStyle.LineChartStyle1, c => { c.Legend.Position = eLegendPosition.Bottom; c.Axis[0].MajorTickMark = eAxisTickMark.None; c.Axis[0].MinorTickMark = eAxisTickMark.None; c.Axis[1].MajorTickMark = eAxisTickMark.None; c.Axis[1].MinorTickMark = eAxisTickMark.None; }); //Style 2 AddLine(ws, chartType, "ColumnChartStyle2", 0, 18, ePresetChartStyle.LineChartStyle2, c => { c.Legend.Position = eLegendPosition.Bottom; c.YAxis.Deleted = true; c.Axis[0].MajorTickMark = eAxisTickMark.None; c.Axis[0].MinorTickMark = eAxisTickMark.None; c.Axis[1].MajorTickMark = eAxisTickMark.None; c.Axis[1].MinorTickMark = eAxisTickMark.None; if (chartType != eLineChartType.Line3D) { c.Marker = true; } c.DataLabel.ShowValue = true; foreach (var serie in c.Series) { if (chartType != eLineChartType.Line3D) { serie.Marker.Style = eMarkerStyle.Circle; serie.Marker.Size = 17; } serie.DataLabel.Position = eLabelPosition.Center; serie.DataLabel.ShowValue = true; } }); //Style 3 AddLine(ws, chartType, "ColumnChartStyle3", 0, 31, ePresetChartStyle.LineChartStyle3, c => { c.DataLabel.ShowPercent = true; c.DataLabel.Position = eLabelPosition.Center; c.AddDropLines(); }); //Style 4 AddLine(ws, chartType, "ColumnChartStyle4", 22, 5, ePresetChartStyle.LineChartStyle4, c => { c.Legend.Position = eLegendPosition.Bottom; }); //Style 5 AddLine(ws, chartType, "ColumnChartStyle5", 22, 18, ePresetChartStyle.LineChartStyle5, c => { c.Legend.Position = eLegendPosition.Bottom; }); //Style 6 AddLine(ws, chartType, "ColumnChartStyle6", 22, 31, ePresetChartStyle.LineChartStyle6, c => { }); //Style 7 AddLine(ws, chartType, "ColumnChartStyle7", 44, 5, ePresetChartStyle.LineChartStyle7, c => { c.Legend.Position = eLegendPosition.Bottom; }); //Style 8 AddLine(ws, chartType, "ColumnChartStyle8", 44, 18, ePresetChartStyle.LineChartStyle8, c => { c.Legend.Position = eLegendPosition.Bottom; }); //Style 9 AddLine(ws, chartType, "ColumnChartStyle9", 44, 31, ePresetChartStyle.LineChartStyle9, c => { }); //Style 10 AddLine(ws, chartType, "ColumnChartStyle10", 66, 5, ePresetChartStyle.LineChartStyle10, c => { c.Legend.Position = eLegendPosition.Bottom; }); //Style 11 AddLine(ws, chartType, "ColumnChartStyle11", 66, 18, ePresetChartStyle.LineChartStyle11, c => { c.Legend.Position = eLegendPosition.Bottom; }); //Style 12 AddLine(ws, chartType, "ColumnChartStyle12", 66, 31, ePresetChartStyle.LineChartStyle12, c => { }); //Style 13 AddLine(ws, chartType, "ColumnChartStyle13", 88, 5, ePresetChartStyle.LineChartStyle13, c => { c.Legend.Position = eLegendPosition.Bottom; }); //Style 14 AddLine(ws, chartType, "ColumnChartStyle14", 88, 18, ePresetChartStyle.LineChartStyle14, c => { c.Legend.Position = eLegendPosition.Bottom; }); //Style 15 AddLine(ws, chartType, "ColumnChartStyle15", 88, 31, ePresetChartStyle.LineChartStyle15, c => { }); }
/// <summary> /// Adds a new line chart to the chart /// </summary> /// <param name="chartType">The type of the new chart</param> /// <returns>The chart</returns> public ExcelLineChart AddLineChart(eLineChartType chartType) { return((ExcelLineChart)Add((eChartType)chartType)); }