/// <summary>
/// 创建图表
/// </summary>
/// <param name="num">个数</param>
/// <returns>空</returns>
private static void CreateChart(Excel._Workbook m_Book, Excel._Worksheet m_Sheet, int num)
{
//Range oResizeRange;
Series oSeries;
m_Book.Charts.Add(Missing.Value, Missing.Value, 1, Missing.Value);
m_Book.ActiveChart.Name = "效果分析图";
m_Book.ActiveChart.ChartType = Excel.XlChartType.xlColumnClustered;//设置图形
//设置数据取值范围
num += 2;
m_Book.ActiveChart.SetSourceData(m_Sheet.get_Range("A3", "C" + num.ToString()) , Excel.XlRowCol.xlColumns);
// TODO: 让12个Bar都显示不同的颜色
ChartGroup grp = (ChartGroup)m_Book.ActiveChart.ChartGroups(1);
grp.GapWidth = 20;
grp.VaryByCategories = true;
// TODO: 让Chart的条目的显示形状变成圆柱形,并给它们显示加上数据标签
Series s = (Series)grp.SeriesCollection(1);
s.BarShape = XlBarShape.xlPyramidToPoint;
s.HasDataLabels = true;
// TODO: 设置统计图的标题和图例的显示
//m_Book.ActiveChart.Legend.Position = XlLegendPosition.xlLegendPositionTop;
//m_Book.ActiveChart.ChartTitle.Border.LineStyle = XlLineStyle.xlContinuous;
//m_Book.ActiveChart.Location(Excel.XlChartLocation.xlLocationAutomatic, title);
/*
//以下是给图表放在指定位置
m_Book.ActiveChart.Location(Excel.XlChartLocation.xlLocationAsObject, m_Sheet.Name);
oResizeRange = (Excel.Range)m_Sheet.Rows.get_Item(10, Missing.Value);
m_Sheet.Shapes.Item("图表 894").Top = (float)(double)oResizeRange.Top; //调图表的位置上边距
oResizeRange = (Excel.Range)m_Sheet.Columns.get_Item(6, Missing.Value); //调图表的位置左边距
// m_Sheet.Shapes.Item("Chart 1").Left = (float)(double)oResizeRange.Left;
m_Sheet.Shapes.Item("图表 894").Width = 400; // 调图表的宽度
m_Sheet.Shapes.Item("图表 894").Height = 250; // 调图表的高度
m_Book.ActiveChart.PlotArea.Interior.ColorIndex = 5; //设置绘图区的背景色
m_Book.ActiveChart.PlotArea.Border.LineStyle = Excel.XlLineStyle.xlLineStyleNone;//设置绘图区边框线条
m_Book.ActiveChart.PlotArea.Width = 400; //设置绘图区宽度
//m_Book.ActiveChart.ChartArea.Interior.ColorIndex = 10; //设置整个图表的背影颜色
//m_Book.ActiveChart.ChartArea.Border.ColorIndex = 8;// 设置整个图表的边框颜色
m_Book.ActiveChart.ChartArea.Border.LineStyle = Excel.XlLineStyle.xlLineStyleNone;//设置边框线条
m_Book.ActiveChart.HasDataTable = false;
//设置Legend图例的位置和格式
m_Book.ActiveChart.Legend.Top = 20.00; //具体设置图例的上边距
m_Book.ActiveChart.Legend.Left = 60.00;//具体设置图例的左边距
m_Book.ActiveChart.Legend.Interior.ColorIndex = Excel.XlColorIndex.xlColorIndexNone;
m_Book.ActiveChart.Legend.Width = 150;
m_Book.ActiveChart.Legend.Font.Size = 9.5;
//m_Book.ActiveChart.Legend.Font.Bold = true;
m_Book.ActiveChart.Legend.Font.Name = "宋体";
//m_Book.ActiveChart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionTop;//设置图例的位置
m_Book.ActiveChart.Legend.Border.LineStyle = Excel.XlLineStyle.xlLineStyleNone;//设置图例边框线条
*/
/*
//设置X轴的显示
Excel.Axis xAxis = (Excel.Axis)m_Book.ActiveChart.Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary);
//xAxis.MajorGridlines.Border.LineStyle = Excel.XlLineStyle.xlDot;
//xAxis.MajorGridlines.Border.ColorIndex = 1;//gridLine横向线条的颜色
xAxis.HasTitle = false;
//xAxis.MinimumScale = 1500;
//xAxis.MaximumScale = 6000;
xAxis.TickLabels.Font.Name = "宋体";
xAxis.TickLabels.Font.Size = 9;
//设置Y轴的显示
Excel.Axis yAxis = (Excel.Axis)m_Book.ActiveChart.Axes(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary);
yAxis.TickLabelSpacing = 30;
//yAxis.TickLabels.NumberFormat = "M月D日";
yAxis.TickLabels.Orientation = Excel.XlTickLabelOrientation.xlTickLabelOrientationHorizontal;//Y轴显示的方向,是水平还是垂直等
yAxis.TickLabels.Font.Size = 8;
yAxis.TickLabels.Font.Name = "宋体";
* */
//m_Book.ActiveChart.Floor.Interior.ColorIndex = 8;
/***以下是设置标题*****
m_Book.ActiveChart.HasTitle=true;
m_Book.ActiveChart.ChartTitle.Text = "净值指数";
m_Book.ActiveChart.ChartTitle.Shadow = true;
m_Book.ActiveChart.ChartTitle.Border.LineStyle = Excel.XlLineStyle.xlContinuous;
*/
oSeries = (Excel.Series)m_Book.ActiveChart.SeriesCollection(1);
//oSeries.Border.ColorIndex = 50;
oSeries.Border.Weight = Excel.XlBorderWeight.xlThick;
//oSeries = (Excel.Series)m_Book.ActiveChart.SeriesCollection(3);
//oSeries.Border.ColorIndex = 6;
//oSeries.Border.Weight = Excel.XlBorderWeight.xlThick;
}
/// <summary>
/// 删除directory目录下的所有文件,包括子目录
/// </summary>
/// <param name="i_directory">路径</param>
/// <returns>空</returns>
public static void DeleteDirectoryContents(string i_directory)
{
DirectoryInfo di = new DirectoryInfo(i_directory);
foreach (FileInfo currFile in di.GetFiles())
currFile.Delete();
foreach (DirectoryInfo currDir in di.GetDirectories())
currDir.Delete(true);
}
3443

被折叠的 条评论
为什么被折叠?



