Example #1
0
 public void Format_XGrids(PowerPoint.Chart myChart, bool hasXGrids, string chType)
 {
     try
     {
         if (chType == "Pie" || chType == "Doughnut")
         {
             if (hasXGrids == true)
             {
                 if (myChart.Axes(XlAxisType.xlCategory).HasMajorGridlines == true)
                 {
                     myChart.Axes(XlAxisType.xlCategory).MajorGridlines.Border.Color     = System.Drawing.Color.FromArgb(127, 127, 127).ToArgb();
                     myChart.Axes(XlAxisType.xlCategory).MajorGridlines.Border.LineStyle = PowerPoint.XlLineStyle.xlDot;
                 }
             }
             else if (hasXGrids == false)
             {
                 myChart.HasAxis[XlAxisType.xlCategory] = false;
             }
         }
     }
     catch (Exception err)
     {
         string errtext = err.Message;
         PPTAttribute.ErrorLog(errtext, "Format_XGrids");
     }
 }
Example #2
0
 //'This function formats the y-grids line style, tick marks, title and ticklables font name, style, size, color, sub-super script, underline
 public void Format_YGrids(PowerPoint.Chart myChart, bool hasYAxis, string chType, bool ch3D)
 {
     try
     {
         bool hasYGrids = false;
         if (chType == "Pie" || chType == "Doughnut")
         {
             return;
         }
         if (chType == "Radar" || (hasYAxis && ch3D == true))
         {
             hasYGrids = true;
         }
         if (hasYGrids == true)
         {
             myChart.Axes(XlAxisType.xlValue).HasMajorGridlines               = true;
             myChart.Axes(XlAxisType.xlValue).MajorGridlines.Border.Color     = System.Drawing.Color.FromArgb(127, 127, 127).ToArgb();
             myChart.Axes(XlAxisType.xlValue).MajorGridlines.Border.LineStyle = PowerPoint.XlLineStyle.xlContinuous;
         }
         else if (hasYGrids == false)
         {
             myChart.Axes(XlAxisType.xlValue).HasMajorGridlines = false;
         }
     }
     catch (Exception err)
     {
         string errtext = err.Message;
         PPTAttribute.ErrorLog(errtext, "Format_YGrids");
     }
 }
Example #3
0
        public void Format_XSeries(PowerPoint.Chart myChart, bool hasYAxis)
        {
            //if (myChart.Axes(XlAxisType.xlValue).HasTitle == true)
            try
            {
                if (myChart.HasAxis[XlAxisType.xlSeriesAxis] == true)
                {
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.LineStyle = PowerPoint.XlLineStyle.xlContinuous;
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.Color     = System.Drawing.Color.FromArgb(127, 127, 127).ToArgb();
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.Weight    = PowerPoint.XlBorderWeight.xlHairline;

                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.MajorTickMark     = PowerPoint.XlTickMark.xlTickMarkOutside;
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.MinorTickMark     = PowerPoint.XlTickMark.xlTickMarkNone;
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.TickLabelPosition = PowerPoint.XlTickLabelPosition.xlTickLabelPositionNextToAxis;;
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.AutoScaleFont     = false;

                    PowerPoint.Font TickLabelsFont = myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font;
                    TickLabelsFont.Name = "Calibri";
                    TickLabelsFont.Bold = MsoTriState.msoFalse;
                    TickLabelsFont.Size = 11;
                    myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                    myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font.Strikethrough = MsoTriState.msoFalse;
                    TickLabelsFont.Superscript = MsoTriState.msoFalse;
                    TickLabelsFont.Subscript   = MsoTriState.msoFalse;
                    myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font.OutlineFont = MsoTriState.msoFalse;
                    TickLabelsFont.Shadow = MsoTriState.msoFalse;
                    myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font.Underline  = XlUnderlineStyle.xlUnderlineStyleNone;
                    myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font.Background = PowerPoint.XlBackground.xlBackgroundAutomatic;
                }
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "Format_XSeries");
            }
        }
Example #4
0
 public void Format_XAxis(PowerPoint.Chart myChart, bool hasXAxis, string chType)
 {
     try
     {
         if (chType == "Pie" || chType == "Doughnut")
         {
             return;
         }
         if (chType == "Radar")
         {
             PowerPoint.Font RALFont = myChart.ChartGroups(1).RadarAxisLabels.Font;
             RALFont.Name = "Calibri";
             RALFont.Bold = MsoTriState.msoFalse;
             RALFont.Size = 11;
             myChart.ChartGroups(1).RadarAxisLabels.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
             myChart.ChartGroups(1).RadarAxisLabels.Font.Strikethrough = MsoTriState.msoFalse;
             RALFont.Superscript = MsoTriState.msoFalse;
             RALFont.Subscript   = MsoTriState.msoFalse;
             myChart.ChartGroups(1).RadarAxisLabels.Font.OutlineFont = MsoTriState.msoFalse;
             RALFont.Shadow = MsoTriState.msoFalse;
             myChart.ChartGroups(1).RadarAxisLabels.Font.Underline  = XlUnderlineStyle.xlUnderlineStyleNone;
             myChart.ChartGroups(1).RadarAxisLabels.Font.Background = PowerPoint.XlBackground.xlBackgroundAutomatic;
             //System.Environment.Exit(0);
         }
         if (hasXAxis == true)
         {
             if (myChart.Axes(XlAxisType.xlCategory).HasTitle == true)
             {
                 PowerPoint.Font AxTitleFont = myChart.Axes(XlAxisType.xlCategory).AxisTitle.Font;
                 AxTitleFont.Name = "Calibri";
                 AxTitleFont.Bold = MsoTriState.msoFalse;
                 AxTitleFont.Size = 11;
                 myChart.Axes(XlAxisType.xlCategory).AxisTitle.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                 myChart.Axes(XlAxisType.xlCategory).AxisTitle.Font.Strikethrough = MsoTriState.msoFalse;
                 AxTitleFont.Superscript = MsoTriState.msoFalse;
                 AxTitleFont.Subscript   = MsoTriState.msoFalse;
                 myChart.ChartGroups(1).RadarAxisLabels.Font.OutlineFont = MsoTriState.msoFalse;
                 AxTitleFont.Shadow = MsoTriState.msoFalse;
                 myChart.Axes(XlAxisType.xlCategory).AxisTitle.Font.Font.Underline  = XlUnderlineStyle.xlUnderlineStyleNone;
                 myChart.Axes(XlAxisType.xlCategory).AxisTitle.Font.Font.Background = PowerPoint.XlBackground.xlBackgroundAutomatic;
             }
             myChart.Axes(XlAxisType.xlCategory).Border.LineStyle         = PowerPoint.XlLineStyle.xlContinuous;
             myChart.Axes(XlAxisType.xlCategory).Border.Color             = System.Drawing.Color.FromArgb(127, 127, 127).ToArgb();
             myChart.Axes(XlAxisType.xlCategory).Border.Weight            = PowerPoint.XlBorderWeight.xlHairline;
             myChart.Axes(XlAxisType.xlCategory).MajorTickMark            = PowerPoint.XlTickMark.xlTickMarkOutside;
             myChart.Axes(XlAxisType.xlCategory).TickLabelPosition        = PowerPoint.XlTickLabelPosition.xlTickLabelPositionNextToAxis;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.AutoScaleFont = false;
             //---
             //PowerPoint.Font TickLabelsFont = myChart.Axes(XlAxisType.xlCategory).TickLabels.Font;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Name          = "Calibri";
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Bold          = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Size          = 11;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Strikethrough = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Superscript   = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Subscript     = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.OutlineFont   = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Shadow        = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Underline     = XlUnderlineStyle.xlUnderlineStyleNone;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Background    = PowerPoint.XlBackground.xlBackgroundAutomatic;
         }
         else if (hasXAxis == false)
         {
             myChart.HasAxis[XlAxisType.xlCategory] = false;
         }
     }
     catch (Exception err)
     {
         string errtext = err.Message;
         PPTAttribute.ErrorLog(errtext, "Format_XAxis");
     }
 }
Example #5
0
        public void Format_YAxis2(PowerPoint.Chart myChart, bool hasYAxis, string chType)
        {
            try
            {
                bool secAxis = false;
                PowerPoint.SeriesCollection sc = myChart.SeriesCollection();
                if (chType == "Pie" || chType == "Doughnut" || chType == "Surface")
                {
                    return;
                }
                if (chType == "Radar" || chType == "Stock")
                {
                    hasYAxis = true;
                }

                for (int i = 1; i <= sc.Count; i++)
                {
                    if (myChart.SeriesCollection(i).AxisGroup == 2)
                    {
                        secAxis = true; break;
                    }                                                                                    //XlAxisGroup.xlSecondary
                }
                if (secAxis == true)
                {
                    if (hasYAxis == true)
                    {
                        myChart.HasAxis[XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary] = true;
                        if (myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).HasTitle == true)
                        {
                            PowerPoint.Font fontObj = myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font;
                            fontObj.Name = "Calibri";
                            fontObj.Bold = MsoTriState.msoTrue;
                            fontObj.Size = 11;
                            myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                            myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Strikethrough = MsoTriState.msoFalse;
                            fontObj.Superscript = MsoTriState.msoFalse;
                            fontObj.Subscript   = MsoTriState.msoFalse;
                            myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.OutlineFont = MsoTriState.msoFalse;
                            fontObj.Shadow = MsoTriState.msoFalse;
                            myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Underline  = XlUnderlineStyle.xlUnderlineStyleNone;
                            myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Background = PowerPoint.XlBackground.xlBackgroundAutomatic;
                        }
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).Border.LineStyle         = PowerPoint.XlLineStyle.xlContinuous;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).Border.Color             = System.Drawing.Color.FromArgb(127, 127, 127).ToArgb();
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).Border.Weight            = PowerPoint.XlBorderWeight.xlHairline;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).MajorTickMark            = PowerPoint.XlTickMark.xlTickMarkOutside;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).TickLabelPosition        = PowerPoint.XlTickLabelPosition.xlTickLabelPositionNextToAxis;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).TickLabels.AutoScaleFont = false;
                        // ------

                        PowerPoint.Font fontObjTB = myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).TickLabels.Font;
                        fontObjTB.Name = "Calibri";
                        fontObjTB.Bold = MsoTriState.msoTrue;
                        fontObjTB.Size = 11;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Strikethrough = MsoTriState.msoFalse;
                        fontObjTB.Superscript = MsoTriState.msoFalse;
                        fontObjTB.Subscript   = MsoTriState.msoFalse;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.OutlineFont = MsoTriState.msoFalse;
                        fontObjTB.Shadow = MsoTriState.msoFalse;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Underline  = XlUnderlineStyle.xlUnderlineStyleNone;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Background = PowerPoint.XlBackground.xlBackgroundAutomatic;
                    }     // Check hasAxis is true
                    else if (hasYAxis == false)
                    {
                        myChart.HasAxis[XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary] = false;
                    }
                }
            } // Close Main if Check the chart type
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "Format_YAxis2");
            }
        }
Example #6
0
        public void Format_YAxis1(PowerPoint.Chart myChart, bool hasYAxis, string chType)
        {
            //If chType = "Radar" Or chType = "Stock" Then hasYAxis = True  'Or ch3D = True
            try
            {
                Microsoft.Office.Interop.Graph.Axis axis;
                if (chType == "Pie" || chType == "Doughnut" || chType == "Surface")
                {
                    return;
                }
                if (chType == "Radar" || chType == "Stock")
                {
                    hasYAxis = true;
                }

                if (hasYAxis == true)
                {
                    //axis = (Microsoft.Office.Interop.Graph.Axis)myChart.Axes(XlAxisType.xlValue);
                    myChart.HasAxis[XlAxisType.xlValue] = true;
                    //myChart.HasAxis = true;
                    if (myChart.Axes(XlAxisType.xlValue).HasTitle == true)
                    {
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.Name          = "Calibri";
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.Bold          = MsoTriState.msoTrue;
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.Size          = 11;
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.Strikethrough = MsoTriState.msoFalse;
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.Superscript   = MsoTriState.msoFalse;
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.Subscript     = MsoTriState.msoFalse;
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.OutlineFont   = MsoTriState.msoFalse;
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.Shadow        = MsoTriState.msoFalse;
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.Underline     = XlUnderlineStyle.xlUnderlineStyleNone;
                        myChart.Axes(XlAxisType.xlValue).AxisTitle.Font.Background    = PowerPoint.XlBackground.xlBackgroundAutomatic;
                    }
                    myChart.Axes(XlAxisType.xlValue).Border.LineStyle         = PowerPoint.XlLineStyle.xlContinuous;      //15/02/2018
                    myChart.Axes(XlAxisType.xlValue).Border.Color             = System.Drawing.Color.FromArgb(127, 127, 127).ToArgb();
                    myChart.Axes(XlAxisType.xlValue).Border.Weight            = PowerPoint.XlBorderWeight.xlHairline;
                    myChart.Axes(XlAxisType.xlValue).MajorTickMark            = PowerPoint.XlTickMark.xlTickMarkOutside;
                    myChart.Axes(XlAxisType.xlValue).TickLabelPosition        = PowerPoint.XlTickLabelPosition.xlTickLabelPositionNextToAxis;
                    myChart.Axes(XlAxisType.xlValue).TickLabels.AutoScaleFont = false;
                    //------
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Name          = "Calibri";
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Bold          = MsoTriState.msoTrue;
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Size          = 11;
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Strikethrough = MsoTriState.msoFalse;
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Superscript   = MsoTriState.msoFalse;
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Subscript     = MsoTriState.msoFalse;
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.OutlineFont   = MsoTriState.msoFalse;
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Shadow        = MsoTriState.msoFalse;
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Bold          = MsoTriState.msoFalse;
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Underline     = XlUnderlineStyle.xlUnderlineStyleNone;
                    myChart.Axes(XlAxisType.xlValue).TickLabels.Font.Background    = PowerPoint.XlBackground.xlBackgroundAutomatic;
                } // - Check HasAxis is True of Not
                else if (hasYAxis == false)
                {
                    myChart.HasAxis[XlAxisType.xlValue] = false;
                }
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "Format_YAxis1");
            }
        }