C# - Snippets
Chart_Add
Add a chart providing the source data, chart type and location.public Excel.Chart Chart_Add(
long lTypeOfChart,
string sColFirst,
int iRowFirst,
string sColLast,
int iRowLast,
bool bPlotByColumn = true,
string sChartLocation = "Embedded Chart",
string sPlaceCol = "",
int iPlaceRow = 0,
string sSourceWshName = "",
string sChartWshName = "")
{
Excel.Worksheet objWorksheet;
Excel.Range objRange;
Excel.Chart objChart;
Excel.XlChartLocation objChartLocation;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (sChartWshName != "")
{
objWorksheet = (Excel.Worksheet)gApplication.Sheets[sChartWshName];
objWorksheet.Select();
}
if (sChartWshName == "")
{
objWorksheet = (Excel.Worksheet)gApplication.ActiveSheet;
sChartWshName = objWorksheet.Name;
}
if (sSourceWshName == "")
sSourceWshName = sChartWshName;
if (gbUPDATE_SCREEN == false)
gApplication.ScreenUpdating = false;
gApplication.Charts.Add();
objChart = (Excel.Chart)gApplication.ActiveChart;
objChart.ChartType = (Excel.XlChartType)lTypeOfChart;
//because Pie and Bubble charts create a chart title by default
objChart.HasTitle = false;
//defaults to columns !!!
objWorksheet = (Excel.Worksheet)gApplication.Sheets[sSourceWshName];
objRange = objWorksheet.Range[sColFirst + iRowFirst + ":" + sColLast + iRowLast];
objChart.SetSourceData(Source: objRange);
if (bPlotByColumn == true)
objChart.PlotBy = Excel.XlRowCol.xlColumns;
if (bPlotByColumn == false)
objChart.PlotBy = Excel.XlRowCol.xlRows;
if (sChartLocation == "Embedded Chart")
{
objChartLocation = Excel.XlChartLocation.xlLocationAsObject;
objChart.Location(Where: objChartLocation, Name: sChartWshName);
}
if (sChartLocation == "Chart Sheet")
{
objChartLocation = Excel.XlChartLocation.xlLocationAsNewSheet;
objChart.Location(Where: objChartLocation);
//change the view % on the chart sheet to 100% - maybe have option to change default
gApplication.ActiveWindow.Zoom = 100;
}
if (gbUPDATE_SCREEN == false)
gApplication.ScreenUpdating = true;
if ((sPlaceCol != "") & (iPlaceRow != 0))
{
Chart_Move(sPlaceCol, iPlaceRow, Chart_NameReturn);
}
Chart_Add = objChart;
//include where to place the chart
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbUPDATE_SCREEN == false)
gApplication.ScreenUpdating = true;
string serrortext = null;
objWorksheet = null;
objRange = null;
objChart = null;
if ((gobjCOMException != null | gobjException != null))
{
gApplication.ScreenUpdating = true;
gApplication.DisplayAlerts = false;
if (Microsoft.VisualBasic.Information.TypeName(gApplication.ActiveSheet) == "Chart")
{
objWorksheet = (Excel.Worksheet)gApplication.ActiveSheet;
objWorksheet.Delete();
}
gApplication.DisplayAlerts = true;
if (sSourceWshName != "")
serrortext = sSourceWshName + "!";
serrortext =
serrortext + sColFirst + iRowFirst + ":" + sColLast + iRowLast + "\" ";
if (sChartWshName == "")
serrortext = serrortext + "on the active worksheet";
if (sChartWshName != "")
serrortext = serrortext + "to the worksheet \"" + sChartWshName + "\"";
}
if (gbDEBUG == true |
(gobjCOMException != null | gobjException != null))
{
clsError.Handle(
"Chart_Add",
msMODULENAME,
"add a chart of type '" + lTypeOfChart + "'" + "\r\n" +
"with the source data '" + serrortext + "'" + "\r\n" +
"and place it at cell '" + sPlaceCol + iPlaceRow + "'." +
" This may not be a valid chart type.",
gobjCOMException,
gobjException
);
}
}
return null;
}
Chart_Format
public void Chart_Format(
Excel.Chart objChart,
string sChartlocation = "Embedded Chart")
{
Excel.ChartArea objChartArea;
Excel.SeriesCollection objSeriesCol;
Excel.Series objSeries;
string schartsize;
int iseriescount;
float sngfontsize;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (gbUPDATE_SCREEN == false)
{
gApplication.ScreenUpdating = false;
}
//need to check the number of series and display a message if too many !!
//define the palette colours for the series
Colour_SeriesIndexDefine();
objChartArea = objChart.ChartArea;
objSeriesCol = (Excel.SeriesCollection)objChart.SeriesCollection();
if (sChartlocation == "Embedded Chart")
{
schartsize = App_ChartSizeReturn(objChart);
sngfontsize = App_ChartFontSize(schartsize);
}
else
{
//otherwise must be "Chart Sheet"
sngfontsize = 14;
//purely for testing !!!
gbUPDATE_SCREEN = false;
}
Chart_AreaFormat(objChart,
gsDEF_FONTNAME,
sngfontsize,
giDEF_FONTCOLOUR_PALETTE,
gsDEF_FONTBACKGROUND,
gbDEF_FONTBOLD,
null, null, null, null, null, null, null, null,
giDEF_PALETTEWHITE);
Chart_PlotAreaFormat(objChart,
null, null, null,
giDEF_PALETTEWHITE);
Chart_LegendFormat(objChart,
gsDEF_FONTNAME,
sngfontsize,
giDEF_FONTCOLOUR_PALETTE,
gsDEF_FONTBACKGROUND,
null, null, null, null, null, null, null, null, null,
giDEF_PALETTEWHITE);
Chart_PlotAreaSizeMove(objChart,
objChartArea.Width, 1,
objChartArea.Height, 1);
Chart_TitleSizePosition(objChart, null, sngfontsize);
Chart_LegendSizePosition(objChart, null, sngfontsize);
if (Chart_AxesExists(objChart, "P", "C") == true)
{
Chart_AxesTitleSizePosition(objChart, "P", "C");
Chart_AxesFormat(objChart, "P", "C");
Chart_AxesXOptions(objChart, "P", "C");
}
if (Chart_AxesExists(objChart, "P", "V") == true)
{
Chart_AxesTitleSizePosition(objChart, "P", "V");
Chart_AxesFormat(objChart, "P", "V");
Chart_AxesXOptions(objChart, "P", "V");
Chart_AxesYScaleAdjustToRP(objChart, "P", "V", false, true);
}
if (Chart_AxesExists(objChart, "S", "C") == true)
{
Chart_AxesTitleSizePosition(objChart, "S", "C");
Chart_AxesFormat(objChart, "S", "C");
Chart_AxesXOptions(objChart, "S", "C");
}
if (Chart_AxesExists(objChart, "S", "V") == true)
{
Chart_AxesTitleSizePosition(objChart, "S", "V");
Chart_AxesFormat(objChart, "S", "V");
Chart_AxesXOptions(objChart, "S", "V");
Chart_AxesYScaleAdjustToRP(objChart, "S", "V", false, true);
}
for (iseriescount = 1; iseriescount <= objSeriesCol.Count; iseriescount++)
{
if (clszLateBindingExcel.ChartSeriesValid(objSeriesCol, iseriescount) == true)
{
objSeries = objSeriesCol.Item(iseriescount);
ChartType_SeriesFormatLineOrArea(objChart, objSeries, iseriescount);
ChartType_SeriesFormat(objChart, "", objSeries, iseriescount);
}
}
//purely for testing !!! to stop flickering with Chart Sheets
gbUPDATE_SCREEN = true;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbUPDATE_SCREEN == false)
{
gApplication.ScreenUpdating = true;
}
objChart = null;
objChartArea = null;
objSeriesCol = null;
objSeries = null;
if (gbDEBUG == true |
((gobjCOMException != null | gobjException != null)))
{
clsError.Handle("Chart_Format", msMODULENAME,
"format the chart completely.",
gobjCOMException, gobjException);
}
}
}
Chart_HeightReturn
public string Chart_HeightReturn()
{
Excel.Worksheet objWorksheet;
Excel.Chart objChart;
Excel.ChartObject objChartObject;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (Chart_InOne() == false)
{
Chart_HeightReturn = "Nothing";
return;
}
objChart = gApplication.ActiveChart;
objWorksheet = (Excel.Worksheet)gApplication.ActiveSheet;
objChartObject = (Excel.ChartObject)objChart.Parent;
Chart_HeightReturn = System.Convert.ToHexString(objChartObject.Height);
}
catch (Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objWorksheet = null;
objChart = null;
if (gbDEBUG == true |
((IsNothing(gobjCOMException) == false | IsNothing(gobjException) == false)))
{
clsError.Handle("Chart_HeightReturn", msMODULENAME,
"return the height of the active chart",
gobjCOMException, gobjException);
}
}
}
Chart_InOne
Returns a boolean indicating if the current selection is inside a chart.public bool Chart_InOne(
bool bInformUser = false)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (Chart_ObjectValid(TypeName(gApplication.Selection)) == true)
{
Chart_InOne = true;
}
else
{
Chart_InOne = false;
}
}
catch (Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
// If bInformUser = True Then
// INCLUDE a message !!
if (gbDEBUG == true |
((IsNothing(gobjCOMException) == false | IsNothing(gobjException) == false)))
{
clsError.Handle("Chart_InOne", msMODULENAME,
"determine if you are in a chart.",
gobjCOMException, gobjException);
}
}
}
Chart_LocationGet
public static string LocationGet(
Excel.Chart objChart)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
switch (TypeName(objChart.Parent))
{
case "Workbook":
case "WorkbookClass":
{
LocationGet = "Chart Sheet";
break;
}
case "ChartObject":
{
LocationGet = "Embedded Chart";
break;
}
default:
{
MsgBox("TypeName(objChart.Parent) = " + TypeName(objChart.Parent));
break;
}
}
}
catch (Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
if (gbDEBUG_EXCEL == true |
((IsNothing(mobjCOMException) == false | IsNothing(mobjException) == false)))
{
clsError.Handle("LocationGet", "clsChart",
"return the location of the active chart, whether chart sheet or embedded.",
mobjCOMException, mobjException);
}
}
}
Chart_Move
public void Chart_Move(
string sPlaceCol,
int iPlaceRow,
string sChartName = "",
string sWshName = "")
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
float sngfromleft;
float sngfromright;
// ActiveWorkbook.Styles("Normal").Font.Name = "Arial"
// ActiveWorkbook.Styles("Normal").Font.Size = 10
sngfromleft = clsCol.WidthToPoints("A", sPlaceCol);
sngfromright = clsRow.HeightToPoints(1, iPlaceRow);
Chart_MoveTopLeft(sngfromleft, sngfromright,
sPlaceCol + iPlaceRow, sChartName);
// ActiveWorkbook.Styles("Normal").Font.Name = "Arial"
// ActiveWorkbook.Styles("Normal").Font.Size = 10
// Selection.Style = "Normal"
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true |
((gobjCOMException != null | gobjException != null)))
{
clsError.Handle("Chart_Move", msMODULENAME,
"move the chart a small distance ??",
gobjCOMException, gobjException);
}
}
}
Chart_MoveTopLeft
public void Chart_MoveTopLeft(
float sngFromLeft,
float sngFromTop,
string sReturnCell = "",
string sChartName = "",
string sWshName = "")
{
Excel.Worksheet objWorksheet;
Excel.Range objRange;
Excel.ChartObject objChartObject;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (sWshName != "")
{
objWorksheet = (Excel.Worksheet)gApplication.Sheets[sWshName];
objWorksheet.Select();
}
else
{
objWorksheet = (Excel.Worksheet)gApplication.ActiveSheet;
}
if (sChartName == "")
sChartName = Chart_NameReturn();
objRange = objWorksheet.Range["A1"];
objRange.Select();
objChartObject = (Excel.ChartObject)objWorksheet.ChartObjects(sChartName);
objChartObject.Left = sngFromLeft;
objChartObject.Top = sngFromTop;
if (sReturnCell != "")
{
objRange = objWorksheet.Range[sReturnCell];
objRange.Select(); //deactivates the chart
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objWorksheet = null;
objRange = null;
objChartObject = null;
if (gbDEBUG == true |
((gobjCOMException != null | gobjException != null)))
{
clsError.Handle("Chart_MoveTopLeft", msMODULENAME,
"move the chart '" + sChartName + "'" + "\r\n" +
sngFromLeft + " from the left" + "\r\n" +
sngFromTop + " from the top" + "\r\n" +
"relative to the worksheet.",
gobjCOMException, gobjException);
}
}
}
Chart_NameGet
public string Chart_NameGet(
string sChartName = "")
{
Excel.Worksheet objWorksheet;
Excel.Chart objChart;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (Chart_InOne() == false)
{
Chart_NameGet = "Nothing";
return;
}
if (sChartName.Length == 0)
{
objChart = gApplication.ActiveChart;
objWorksheet = (Excel.Worksheet)gApplication.ActiveSheet;
sChartName = objChart.Name;
Chart_NameGet = sChartName.Substring(Len(objWorksheet.Name) + 1);
}
else
Chart_NameGet = sChartName;
}
catch (Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objWorksheet = null;
objChart = null;
if (gbDEBUG == true |
((IsNothing(gobjCOMException) == false | IsNothing(gobjException) == false)))
{
clsError.Handle("Chart_NameReturn", msMODULENAME,
"return the name of the active chart.",
gobjCOMException, gobjException);
}
}
}
Chart_NameReturn
public string Chart_NameReturn(
bool bSelectCell = false)
{
Excel.Worksheet objWorksheet;
Excel.Range objRange;
Excel.Chart objChart;
string sChartName;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (Chart_InOne() == false)
{
Chart_NameReturn = "Nothing";
return;
}
objChart = gApplication.ActiveChart;
objWorksheet = (Excel.Worksheet)gApplication.ActiveSheet;
sChartName = objChart.Name;
Chart_NameReturn = sChartName.Substring(Len(objWorksheet.Name) + 1);
if (bSelectCell == true)
{
objRange = objWorksheet.Range("A1");
objRange.Select();
}
}
catch (Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objWorksheet = null;
objRange = null;
objChart = null;
if (gbDEBUG == true |
((IsNothing(gobjCOMException) == false | IsNothing(gobjException) == false)))
{
clsError.Handle("Chart_NameReturn", msMODULENAME,
"return the name of the active chart",
gobjCOMException, gobjException);
}
}
}
Chart_ObjectValid
public bool Chart_ObjectValid(
string sObjectName)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
switch (sObjectName + Strings.Space(12 - sObjectName.Length))
{
default:
{
// Call MsgBox(sObjectName & " - Chart_ObjectValid")
Chart_ObjectValid = false;
break;
}
}
}
catch (Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true |
((IsNothing(gobjCOMException) == false | IsNothing(gobjException) == false)))
{
clsError.Handle("Chart_ObjectValid", msMODULENAME,
"determine if the object '" + sObjectName + "' is a valid chart object.",
gobjCOMException, gobjException);
}
}
}
Chart_Size
public void Chart_Size(
double dbWidth,
double dbHeight,
string sDeSelectCell = "",
string sChartName = "",
string sWshName = "")
{
Excel.Worksheet objWorksheet;
Excel.ChartObject objChartObject;
Excel.Range objRange;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (sWshName.Length > 0)
{
objWorksheet = (Excel.Worksheet)gApplication.Worksheets[sWshName];
objWorksheet.Select();
}
else
{
objWorksheet = (Excel.Worksheet)gApplication.ActiveSheet;
}
if (sChartName.Length == 0)
{
sChartName = Chart_NameReturn();
}
objChartObject = (Excel.ChartObject)objWorksheet.ChartObjects(sChartName);
objChartObject.Height = dbHeight;
objChartObject.Width = dbWidth;
objChartObject.Activate();
if (sDeSelectCell != "")
{
objRange = (Excel.Range)objWorksheet.Range[sDeSelectCell];
objRange.Select();
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objWorksheet = null;
objChartObject = null;
objRange = null;
if (gbDEBUG == true |
((gobjCOMException != null | gobjException != null)))
{
clsError.Handle("Chart_Size", msMODULENAME,
"size the chart " + Chart_NameGet(sChartName),
gobjCOMException, gobjException);
}
}
}
Chart_SizeObj
public void Chart_SizeObj(
Excel.Chart objChart,
double dbWidth,
double dbHeight)
{
Excel.ChartObject objChartObject;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objChartObject = (Excel.ChartObject)objChart.Parent;
objChartObject.Height = dbHeight;
objChartObject.Width = dbWidth;
}
catch (Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChartObject = null;
if (gbDEBUG == true |
((IsNothing(gobjCOMException) == false | IsNothing(gobjException) == false)))
{
clsError.Handle("Chart_SizeObj", msMODULENAME,
"change the chart object to the following size:" +
Constants.vbCrLf +
"Width: '" + dbWidth + "'" +
Constants.vbCrLf +
"Height: '" + dbHeight + "'",
gobjCOMException, gobjException);
}
}
}
Chart_WidthReturn
public string Chart_WidthReturn()
{
Excel.Worksheet objWorksheet;
Excel.Chart objChart;
Excel.ChartObject objChartObject;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (Chart_InOne() == false)
{
Chart_WidthReturn = "Nothing";
return;
}
objChart = gApplication.ActiveChart;
objWorksheet = (Excel.Worksheet)gApplication.ActiveSheet;
objChartObject = (Excel.ChartObject)objChart.Parent;
Chart_WidthReturn = System.Convert.ToHexString(objChartObject.Width);
}
catch (Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objWorksheet = null;
objChart = null;
if (gbDEBUG == true |
((IsNothing(gobjCOMException) == false | IsNothing(gobjException) == false)))
{
clsError.Handle("Chart_WidthReturn", msMODULENAME,
"return the width of the active chart",
gobjCOMException, gobjException);
}
}
}
ChartAxis_Category_IsValueAxis
public bool ChartAxis_CategoryIsValueAxis(
Excel.Axis objAxis)
{
XlScaleType enscaletype;
try
{
enscaletype = objAxis.ScaleType;
return true;
}
catch
{
return false;
}
}
ChartAxis_Exists
public bool ChartAxis_Exists(
Excel.Chart objChart,
string sAxisGroup,
string sAxisType,
bool bInformUser = false)
{
try
{
if (clsError.ErrorFlag() == true)
{
return false;
}
if (ChartType_SeriesTypeIsItPie((Excel.Series)objChart.SeriesCollection(1)) == true ||
ChartType_SeriesTypeIsItDoughnut((Excel.Series)objChart.SeriesCollection(1)) == true ||
ChartType_SeriesTypeIsItSurface((Excel.Series)objChart.SeriesCollection(1)) == true ||
ChartType_SeriesTypeIsIt3D((Excel.Series)objChart.SeriesCollection(1)))
{
return false;
}
else
{
return Convert.ToBoolean(
objChart.HasAxis(
zReturn_AxisType(sAxisType),
zReturn_AxisGroup(sAxisGroup)
)
);
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (bInformUser == true)
{
App_MessageChartTypeDoesNotExist(sAxisGroup, sAxisType);
}
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_Exists",
msMODULENAME,
"determine if the chart axes: " +
"Axis Group - " + sAxisGroup + " Axis Type - " + sAxisType + " exists.",
gobjCOMException,
gobjException
);
}
}
return false;
}
ChartAxis_Format
public void ChartAxis_Format(
Excel.Chart objChart,
string sAxisGroup,
string sAxisType,
int iAxisColourIdx = giDEF_PALETTEAXESCOLOUR)
{
Excel.Axis objAxis;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objAxis = (Excel.Axis)objChart.Axes(
zReturn_AxisType(sAxisType),
zReturn_AxisGroup(sAxisGroup));
{
var withBlock = objAxis;
// .Border.Color =
withBlock.Border.ColorIndex = iAxisColourIdx;
withBlock.Border.Weight = Excel.XlBorderWeight.xlHairline;
withBlock.Border.LineStyle = Excel.XlLineStyle.xlContinuous;
if (withBlock.HasMajorGridlines == true)
{
withBlock.MajorGridlines.Border.ColorIndex = iAxisColourIdx;
withBlock.MajorTickMark = Excel.XlTickMark.xlTickMarkOutside;
}
if (withBlock.HasMinorGridlines == true)
{
withBlock.MinorGridlines.Border.ColorIndex = iAxisColourIdx;
withBlock.MinorTickMark = Excel.XlTickMark.xlTickMarkNone;
}
withBlock.TickLabelPosition =
Excel.XlTickLabelPosition.xlTickLabelPositionNextToAxis;
withBlock.TickLabels.Orientation =
Excel.XlTickLabelOrientation.xlTickLabelOrientationHorizontal;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objAxis = null;
if (gbDEBUG == true |
((gobjCOMException != null | gobjException != null)))
{
clsError.Handle(
"ChartAxis_Format",
msMODULENAME,
"format the chart axis " +
"AxisGroup - " + sAxisGroup +
" AxisType - " + sAxisType + " axis.",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_ScaleAdjustmentLargest
public float ChartAxis_ScaleAdjustmentLargest(
float sngSmallest,
float sngLargest,
float sngAccuracy = 0.01f)
{
float sngdifference;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
//calculate the actual difference
sngdifference = Math.Abs(sngLargest - sngSmallest);
if ((sngSmallest != 0) && (sngdifference < sngSmallest))
{
if (sngLargest < 0)
sngLargest = sngLargest - (sngdifference * sngAccuracy);
if (sngLargest > 0)
sngLargest = sngLargest + (sngdifference * sngAccuracy);
}
if ((sngSmallest != 0) && (sngSmallest < sngdifference))
{
// I DONT THINK WE NEED BOTH OF THESE !!
if (sngLargest < 0)
sngLargest = sngLargest + (sngLargest * sngAccuracy);
if (sngLargest > 0)
sngLargest = sngLargest + (sngLargest * sngAccuracy);
}
ChartAxis_LargestAdjustment = sngLargest;
return sngLargest;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_LargestAdjustment",
msMODULENAME,
"return the adjusted number for the largest value on an axis.",
gobjCOMException,
gobjException
);
}
}
return 0;
}
ChartAxis_ScaleAdjustmentSmallest
public float ChartAxis_ScaleAdjustmentSmallest(
float sngSmallest,
float sngLargest,
float sngAccuracy = 0.01f)
{
float sngdifference;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
//calculate the actual difference
sngdifference = Math.Abs(sngLargest - sngSmallest);
if ((sngSmallest != 0) && (sngdifference < sngSmallest))
{
if (sngSmallest < 0)
{
sngSmallest = sngSmallest + (sngdifference * sngAccuracy);
}
if (sngSmallest > 0)
{
sngSmallest = sngSmallest - (sngdifference * sngAccuracy);
}
}
if ((sngSmallest != 0) && (sngSmallest < sngdifference))
{
if (sngSmallest < 0)
{
sngSmallest = sngSmallest + (sngSmallest * sngAccuracy);
}
if (sngSmallest > 0)
{
sngSmallest = sngSmallest - (sngSmallest * sngAccuracy);
}
}
ChartAxis_SmallestAdjustment = sngSmallest;
return sngSmallest;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_SmallestAdjustment",
msMODULENAME,
"return the adjusted number for the smallest value on an axis.",
gobjCOMException,
gobjException
);
}
}
return 0;
}
ChartAxis_TitleSizePosition
public void ChartAxis_TitleSizePosition(
Excel.Chart objChart,
string sAxisGroup = "P",
string sAxisType = "V",
bool bBold = false)
{
Excel.Window objWindow;
Excel.Worksheet objWorksheet;
Excel.ChartObject objChartObject;
Excel.Axis objAxis;
Excel.Range objRange;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
int ibeforewindowpercent;
string scurrentname;
//scurrentname = Chart_NameReturn(True)
//gApplication.ScreenUpdating = False
//objWindow = CType(gApplication.ActiveWindow, Excel.Window)
//ibeforewindowpercent = CInt(objWindow.Zoom)
//objWindow.Zoom = 50 'reduce screen to position title - CHECK WE NEED !!
//objWsh = CType(gApplication.ActiveSheet, Excel.Worksheet)
//objChartObject = CType(objWsh.ChartObjects(scurrentname), Excel.ChartObject)
//objChartObject.Activate()
//objChart = objChartObject.Chart
//objChart = CType(gApplication.ActiveChart, Excel.Chart)
objAxis = (Excel.Axis)objChart.Axes(
zReturn_AxisType(sAxisType),
zReturn_AxisGroup(sAxisGroup));
{
var withBlock = objChart;
if (objAxis.HasTitle == true)
{
if (bBold == true)
objAxis.AxisTitle.Font.Bold = bBold;
//---------------------
if (sAxisGroup == "P" && sAxisType == "C")
{
withBlock.PlotArea.Top = 1;
withBlock.PlotArea.Height = withBlock.ChartArea.Height;
withBlock.PlotArea.Height = withBlock.PlotArea.Height - giDEF_AXISTITLESPACE;
//Selection.AxisTitle.Left = needs to be centered !!!!
objAxis.AxisTitle.Top = withBlock.ChartArea.Height - giDEF_AXISTITLESPACE;
objAxis.AxisTitle.Orientation = 0; //title is horizontal
}
//---------------------
if (sAxisGroup == "P" && sAxisType == "V")
{
withBlock.PlotArea.Width = withBlock.ChartArea.Width;
withBlock.PlotArea.Width = withBlock.PlotArea.Width - giDEF_AXISTITLESPACE - 4;
withBlock.PlotArea.Left = 1;
withBlock.PlotArea.Left = withBlock.PlotArea.Left + giDEF_AXISTITLESPACE;
objAxis.AxisTitle.Top = withBlock.PlotArea.Height;
objAxis.AxisTitle.Top = (int)(objAxis.AxisTitle.Top / 2) - giDEF_XAXESSPACE;
objAxis.AxisTitle.Left = 1;
objAxis.AxisTitle.Orientation = 90; //title is 90 degrees
}
//---------------------
if (sAxisGroup == "S" && sAxisType == "C")
{
withBlock.PlotArea.Height = withBlock.ChartArea.Height - (2 * giDEF_AXISTITLESPACE);
withBlock.PlotArea.Top = withBlock.PlotArea.Top + giDEF_AXISTITLESPACE;
//Selection.AxisTitle.Left = needs to be centered !!!!
objAxis.AxisTitle.Top = 1;
objAxis.AxisTitle.Orientation = 0; //title is horizontal
}
//---------------------
if (sAxisGroup == "S" && sAxisType == "V")
{
withBlock.PlotArea.Width = withBlock.ChartArea.Width;
withBlock.PlotArea.Width = withBlock.PlotArea.Width - giDEF_AXISTITLESPACE;
//plotarea.left == as the width is reduced should move left automatically
objAxis.AxisTitle.Top = withBlock.PlotArea.Height;
objAxis.AxisTitle.Top = (int)(objAxis.AxisTitle.Top / 2) - giDEF_XAXESSPACE;
objAxis.AxisTitle.Left = withBlock.ChartArea.Width - giDEF_AXISTITLESPACE + 2;
objAxis.AxisTitle.Orientation = -90; //title is vertical reading right
}
//---------------------
}
}
//objRange = CType(objWsh.Range("A1"), Excel.Range)
//objRange.Select()
//objWindow.Zoom = ibeforewindowpercent 'return the zoom percentage
//objChartObject.Activate()
//gApplication.ScreenUpdating = True
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
objWindow = null;
objWorksheet = null;
objChartObject = null;
objAxis = null;
objRange = null;
if (gbDEBUG == true |
((gobjCOMException != null | gobjException != null)))
{
clsError.Handle(
"ChartAxis_TitleSizePosition",
msMODULENAME,
"size and position the axis title for the chart axis " +
"AxisGroup - " + sAxisGroup + " AxisType - " + sAxisType + " axis.",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_XCalculateNoOfLabels
public double ChartAxis_XCalculateNoOfLabels(
double dbDaysDifference)
{
int icount;
int ismallestlabelno;
int ismallestremainder;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
ismallestlabelno = 5;
ismallestremainder = System.Convert.ToInt32(dbDaysDifference % ismallestlabelno);
for (icount = 5; icount >= 3; icount += -1)
{
if (dbDaysDifference % icount == 0)
{
ismallestremainder = System.Convert.ToInt32(dbDaysDifference % icount);
ismallestlabelno = icount;
break;
}
else if (dbDaysDifference % icount < ismallestremainder)
{
ismallestremainder = System.Convert.ToInt32(dbDaysDifference % icount);
ismallestlabelno = icount;
}
}
return Math.Ceiling(dbDaysDifference / ismallestlabelno);
}
catch (Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true |
((IsNothing(gobjCOMException) == false | IsNothing(gobjException) == false)))
{
clsError.Handle("ChartAxis_XCalculateNoOfLabels", msMODULENAME,
"return the number of labels required for the X-axis.",
gobjCOMException, gobjException);
}
}
}
ChartAxis_XOptions
public void ChartAxis_XOptions(
Excel.Chart objChart,
string sAxisGroup = "P",
string sAxisType = "V",
string sAxisCategory = "AS",
bool bAxisShowIt = true,
string sAxisBaseUnit = "D",
string sAxisMajorUnit = "M",
string sAxisMinorUnit = "M",
string sMajorTickMarkPos = "OU",
string sMinorTickMarkPos = "OU",
string sTickLabelPos = "NA",
bool bMinorGridlines = false,
bool bMajorGridlines = false,
string sTickLabelFormat = "",
string sTickLabelsOrientation = "AU",
int iTickLabelSpacing = 1,
int iTickMarkSpacing = 1,
bool bAxisBetweenCategories = true,
int iAxisCrossesAt = 0)
{
object objSelection;
Excel.Axis objAxis;
double dbnoofdaysdifference;
int iminimumdate;
int imaximumdate; //declares for dates
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objAxis = (Excel.Axis)objChart.Axes(
zReturn_AxisType(sAxisType),
zReturn_AxisGroup(sAxisGroup));
//this automatically selects the whole chart area
objSelection = gApplication.Selection;
objChart.HasAxis(
zReturn_AxisType(sAxisType),
zReturn_AxisGroup(sAxisGroup)) = true;
//Throw New System.Exception("testing")
{
var withBlock = objAxis;
if (sAxisType == "C")
{
if (withBlock.CategoryType == Excel.XlCategoryType.xlAutomaticScale)
{
withBlock.CategoryType = zReturn_AxisCategoryType(sAxisCategory);
}
if (withBlock.CategoryType == Excel.XlCategoryType.xlTimeScale ||
sAxisCategory == "TS")
{
withBlock.BaseUnit = zReturn_TimeSeriesUnit(sAxisBaseUnit);
}
}
withBlock.MinorTickMark = zReturn_TickMarkPosition(sMinorTickMarkPos);
withBlock.MajorTickMark = zReturn_TickMarkPosition(sMajorTickMarkPos);
//check that if the chart has gridlines they are deleted ????
withBlock.TickLabelPosition = zReturn_TickLabelPosition(sTickLabelPos);
//gridlines only for primary axes except 3D charts ??
//either primary axes either primary or secondary
if (sAxisGroup == "P")
{
withBlock.HasMajorGridlines = bMajorGridlines;
withBlock.HasMinorGridlines = bMinorGridlines;
// If sAxisType = "C" Then .CrossesAt = lAxisCrossesAt few chart types ?
}
//.ReversePlotOrder = False 'cannot be used on radar charts
if (sAxisType == "C")
{
//------------------------- automatic
if (withBlock.CategoryType == Excel.XlCategoryType.xlAutomaticScale)
{
if (sTickLabelFormat != "")
withBlock.TickLabels.NumberFormat = sTickLabelFormat;
else
withBlock.TickLabels.NumberFormat = "0";
withBlock.TickLabels.Orientation =
zReturn_TickLabelOrientation(sTickLabelsOrientation);
}
//------------------------- category
if (withBlock.CategoryType == Excel.XlCategoryType.xlCategoryScale)
{
if (sTickLabelFormat != "")
withBlock.TickLabels.NumberFormat = sTickLabelFormat;
else
withBlock.TickLabels.NumberFormat = "General";
withBlock.AxisBetweenCategories = bAxisBetweenCategories;
withBlock.TickLabelSpacing = iTickLabelSpacing;
withBlock.TickMarkSpacing = iTickMarkSpacing;
withBlock.TickLabels.Orientation =
zReturn_TickLabelOrientation(sTickLabelsOrientation);
}
//------------------------- time scale
if (withBlock.CategoryType == Excel.XlCategoryType.xlTimeScale)
{
if (sTickLabelFormat != "")
withBlock.TickLabels.NumberFormat = sTickLabelFormat;
else
withBlock.TickLabels.NumberFormat = "d-mmm-yy";
withBlock.BaseUnit = zReturn_TimeSeriesUnit(sAxisBaseUnit);
dbnoofdaysdifference = withBlock.MaximumScale - withBlock.MinimumScale;
withBlock.MajorUnit = ChartAxis_XCalculateNoOfLabels(dbnoofdaysdifference);
withBlock.MinorUnit = withBlock.MajorUnit; //default to show no minor tickmarks
withBlock.MajorUnitScale = Excel.XlTimeUnit.xlDays;
withBlock.MinorUnitScale = withBlock.MajorUnitScale;
// .Crosses = lAxisCrossesAt 'not radar charts !
withBlock.AxisBetweenCategories = bAxisBetweenCategories;
withBlock.ReversePlotOrder = false;
withBlock.TickLabels.Orientation =
zReturn_TickLabelOrientation(sTickLabelsOrientation);
}
//-------------------------
}
}
objChart.HasAxis(
zReturn_AxisType(sAxisType),
zReturn_AxisGroup(sAxisGroup)) = bAxisShowIt;
clszLateBindingExcel.ChartSelectionActivate(objSelection);
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objAxis = null;
if (gbDEBUG == true |
((gobjCOMException != null | gobjException != null)))
{
clsError.Handle(
"ChartAxis_XOptions",
msMODULENAME,
"define the axis options for the chart axis " +
"AxisGroup - " + sAxisGroup +
" AxisType - " + sAxisType + " axis.",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_YCalculateXLines
public void ChartAxis_YCalculateXLines(
int iarrayno,
float sngdifference)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
//the correct power of 10 to multiple the ideal scale by
float sngMultipleFactor;
int iIdealPowerof10;
//giIdealPowerof10(iarrayno) = clsNumber.ReturnPowerOfTen(sngdifference / iarrayno)
iIdealPowerof10 = clsNumber.ReturnPowerOfTen(sngdifference / iarrayno);
//gsngMultipleFactor = clsNumber.TenToThePowerOf(giIdealPowerof10(iarrayno))
gsngMultipleFactor = clsNumber.TenToThePowerOf(iIdealPowerof10);
giAppScaleMultiple[iarrayno] =
(int)(ChartAxis_YScaleChoose((sngdifference / iarrayno) * gsngMultipleFactor));
gsngActualScale[iarrayno] = giAppScaleMultiple[iarrayno] / gsngMultipleFactor;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YCalculateXLines",
msMODULENAME,
"calculate the corresponding number of X lines for the " +
"Array No: " + iarrayno + " and Difference: " + sngdifference + ".",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_YDecimalPlaces
public void ChartAxis_YDecimalPlaces(
Excel.Chart objChart,
string sAxisGroup,
string sAxisType,
int iDecimalPlaces)
{
Excel.Axis objAxis;
Excel.SeriesCollection objSeriesCol;
Excel.Series objSeries;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
string splaces;
int icount;
bool bstacked100 = false;
splaces = "0.";
for (icount = 0; icount < iDecimalPlaces; icount++)
{
splaces = splaces + "0";
}
objAxis = (Excel.Axis)objChart.Axes(
zReturn_AxisType(sAxisType),
zReturn_AxisGroup(sAxisGroup));
//-----------------------
objSeriesCol = (Excel.SeriesCollection)objChart.SeriesCollection();
for (icount = 1; icount <= objSeriesCol.Count; icount++)
{
objSeries = objSeriesCol.Item(icount);
if (Chart_SeriesAxisUsed(objSeries) == sAxisGroup)
{
//is series on the axis
if (ChartType_SeriesTypeIsItStacked100(objSeries) == true)
{
bstacked100 = true;
}
}
}
//-----------------------
if (bstacked100 == true)
{
//then the axis is for a stacked 100
//decimal places set before in format stacked
}
else
{
//therefore chart is not 100% so set the decimal places
//temporarily set to General if RP scaling is not in effect
//objAxis.TickLabels.NumberFormat = "General"
if (iDecimalPlaces == 0)
{
objAxis.TickLabels.NumberFormat = "0";
}
else
{
objAxis.TickLabels.NumberFormat = splaces;
}
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
objAxis = null;
objSeriesCol = null;
objSeries = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YDecimalPlaces",
msMODULENAME,
"adjust the number of decimal places on the " +
"(" + sAxisGroup + ") Y axis.",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_YScaleAdjustStart
public float ChartAxis_YScaleAdjustStart(
float sngSmallest,
float sngBestScaleUnits)
{
int icount;
float sngrunning;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
icount = 0;
sngrunning = 0; //shouldn't need this ! - why would it be zero
if (sngBestScaleUnits != 0)
{
icount = (int)((Math.Abs(sngSmallest) - sngBestScaleUnits) / sngBestScaleUnits);
sngrunning = sngBestScaleUnits * icount;
while (sngrunning > Math.Abs(sngSmallest) == false)
{
icount = icount + 1;
sngrunning = sngBestScaleUnits * icount;
}
}
if (sngSmallest > 0)
{
ChartAxes_YScaleAdjustStart = (icount - 1) * sngBestScaleUnits;
return (icount - 1) * sngBestScaleUnits;
}
if (sngSmallest < 0)
{
ChartAxes_YScaleAdjustStart = sngrunning;
return sngrunning;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleAdjustStart",
msMODULENAME,
"return the starting scale for an axis.",
gobjCOMException,
gobjException
);
}
}
return 0;
}
ChartAxis_YScaleAdjustToMicrosoft
public void ChartAxis_YScaleAdjustToMicrosoft(
Excel.Chart objChart,
string sAxisGroup = "P",
string sAxisType = "V")
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (ChartAxis_Exists(objChart, sAxisGroup, sAxisType) == true)
{
ChartAxis_YScaleMicrosoft(objChart, sAxisGroup);
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleAdjustToMicrosoft",
msMODULENAME,
"adjusts the scales of the axes to the 'Microsoft Automatic' scaling.",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_YScaleAdjustToRP
public void ChartAxis_YScaleAdjustToRP(
Excel.Chart objChart,
string sAxisGroup = "P",
string sAxisType = "V",
bool bToZeroScaling = false,
bool bMicrosoftScale = false)
{
Excel.SeriesCollection objSeriesCol;
Excel.Series objSeries;
float sngSmallest = 0;
float sngLargest = 0;
int icount;
bool bnotstacked = false;
bool bmultiplestacked = false;
System.Array arrseriesvalues;
float[] sngseriesarray;
float[] sngcurrenttotal = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objSeriesCol = (Excel.SeriesCollection)objChart.SeriesCollection();
if (ChartAxis_Exists(objChart, sAxisGroup, sAxisType) == true)
{
bnotstacked = false;
bmultiplestacked = false; //to determine if multiple series are stacked
for (icount = 1; icount <= objSeriesCol.Count; icount++)
{
objSeries = objSeriesCol.Item(icount);
//is the series on a given axis
if (Chart_SeriesAxisUsed(objSeries) == sAxisGroup)
{
//------------------------------------------------
if (ChartType_SeriesTypeIsItStacked100(objSeries) == false)
{
arrseriesvalues = (System.Array)objSeries.Values;
sngseriesarray = clsArray.ArrayToSingleArray(arrseriesvalues);
if (ChartType_SeriesTypeIsItStacked(objSeries) == true)
{
//chart is STACKED
//------------------------------
if (bmultiplestacked == false)
{
//assign this first series to the temp array
sngcurrenttotal = sngseriesarray;
sngSmallest = clsArray.ValueSmallestSingle("Smallest", sngcurrenttotal, sngSmallest);
sngLargest = clsArray.ValueLargestSingle("Largest", sngcurrenttotal, sngLargest);
//first series, so next one will be stacked
bmultiplestacked = true;
}
else
{
//series is stacked on top of a previous series
sngcurrenttotal = clsArray.Arrays2AddSingle(
"Current Total", sngcurrenttotal,
"Next Series", sngseriesarray);
//calculate smallest & largest from the sum series using this axis
sngSmallest = clsArray.ValueSmallestSingle("Smallest", sngcurrenttotal, sngSmallest);
sngLargest = clsArray.ValueLargestSingle("Largest", sngcurrenttotal, sngLargest);
}
//------------------------------
}
else
{
//chart is not STACKED
//------------------------------
if (bnotstacked == false)
{
sngSmallest = clsArray.ValueSmallestSingle("Smallest", sngseriesarray, sngSmallest);
sngLargest = clsArray.ValueLargestSingle("Largest", sngseriesarray, sngLargest);
bnotstacked = true;
}
else
{
sngSmallest = clsArray.ValueSmallestSingle("Smallest", sngseriesarray, sngSmallest);
sngLargest = clsArray.ValueLargestSingle("Largest", sngseriesarray, sngLargest);
}
//------------------------------
}
}
else
{
if (bMicrosoftScale == false)
{
ChartAxis_YScaleDefine(objChart, sAxisGroup, sAxisType, 0, 100, 20);
ChartAxis_YDecimalPlaces(objChart, sAxisGroup, sAxisType, 0);
return;
}
else
{
ChartAxis_YScaleDefine(objChart, sAxisGroup, sAxisType, 0, 100);
ChartAxis_YDecimalPlaces(objChart, sAxisGroup, sAxisType, 0);
}
}
//------------------------------------------------
}
}
if (bMicrosoftScale == false)
{
if (bToZeroScaling == false)
{
ChartAxis_YScaleAutomatic(objChart, sAxisGroup, sAxisType,
sngSmallest, sngLargest);
}
else
{
ChartAxis_YScaleAutomatic(objChart, sAxisGroup, sAxisType,
0, sngLargest);
}
}
else
{
ChartAxis_YScaleMicrosoft(objChart, sAxisGroup);
//include an option either always have 2 decimal places or automatic
//Call Chart_AxesYDecimalPlaces(objChart, sAxisGroup, sAxisType, 2)
ChartAxis_YScaleMicrosoftAlterDecimalPlaces(objChart, sAxisGroup, sAxisType);
}
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objSeriesCol = null;
objSeries = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleAdjustToRP",
msMODULENAME,
"determine the smallest and largest values for the scales on the axis " +
" AxisGroup - " + sAxisGroup + " AxisType - " + sAxisType + ".",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_YScaleAdjustToRPBracket
public void ChartAxis_YScaleAdjustToRPBracket(
Excel.Chart objChart,
string sAxisGroup,
string sAxisType,
float sngsmallestvalue,
float snglargestvalue,
float sngIdealStart,
float sngIdealFinish,
float sngIdealScale)
{
float sngBestScaleUnits;
int iarrayno;
float sngdifference;
float sngSmallest;
float sngLargest;
float sngstartscale;
float sngfinishscale;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
sngSmallest = clsNumber.SmallestOneSingle(sngsmallestvalue, snglargestvalue);
sngLargest = clsNumber.LargestOneSingle(sngsmallestvalue, snglargestvalue);
sngdifference = Math.Abs(sngIdealFinish - sngIdealStart);
if (clsNumber.IsItInRange(sngSmallest, sngIdealStart, sngIdealFinish) == true &&
clsNumber.IsItInRange(sngLargest, sngIdealStart, sngIdealFinish) == true)
{
Array.Resize(ref giAppScaleMultiple, giDEF_AXISSCALEMAX + 1);
Array.Resize(ref gsngActualScale, giDEF_AXISSCALEMAX + 1);
for (iarrayno = giDEF_AXISSCALEMIN; iarrayno <= giDEF_AXISSCALEMAX; iarrayno++)
{
ChartAxis_YCalculateXLines(iarrayno, sngdifference);
}
sngstartscale = sngIdealStart;
sngBestScaleUnits = sngIdealScale; //use the ideal scale given
giNoofLinesChosen = (int)((sngIdealFinish - sngIdealStart) / sngIdealScale);
gsngMultipleFactor = clsNumber.TenToThePowerOf(giNoofLinesChosen);
sngfinishscale = sngIdealFinish;
ChartAxis_YScaleDefine(objChart, sAxisGroup, sAxisType,
sngstartscale, sngfinishscale,
sngBestScaleUnits);
ChartAxis_YScaleAlterDecimalPlaces(objChart, sAxisGroup, sAxisType,
sngBestScaleUnits);
}
else
{
sngSmallest = ChartAxis_SmallestAdjustment(sngSmallest, sngLargest,
gsngBRACKETCHARTACCURACY); //fn above
sngLargest = ChartAxis_LargestAdjustment(sngSmallest, sngLargest,
gsngBRACKETCHARTACCURACY); //fn above
sngfinishscale = sngSmallest;
if ((sngLargest - sngSmallest) < sngdifference)
{
do
{
sngBestScaleUnits = sngIdealScale; //use the ideal scale given
sngstartscale =
ChartAxis_YScaleGetStart(objChart, sngSmallest, sngBestScaleUnits);
giNoofLinesChosen =
(int)((sngIdealFinish - sngIdealStart) / sngIdealScale);
gsngMultipleFactor = clsNumber.TenToThePowerOf(giNoofLinesChosen);
sngfinishscale =
ChartAxis_YScaleGetFinish(objChart, sngstartscale, sngBestScaleUnits);
//increments diff. if not successful
sngIdealFinish = (float)(sngIdealFinish * 1.01);
}
while (sngfinishscale <= sngLargest);
ChartAxis_YScaleDefine(objChart, sAxisGroup, sAxisType,
sngstartscale, sngfinishscale,
sngBestScaleUnits);
ChartAxis_YScaleAlterDecimalPlaces(objChart, sAxisGroup, sAxisType,
sngBestScaleUnits);
}
else
{
ChartAxis_YScaleAutomatic(objChart, sAxisGroup, sAxisType,
sngSmallest, sngLargest);
}
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleAdjustToRPBracket",
msMODULENAME,
"adjust the scales of the axes to the 'RP Bracket Automatic' scaling.",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_YScaleAlterDecimalPlaces
public void ChartAxis_YScaleAlterDecimalPlaces(
Excel.Chart objChart,
string sAxisGroup,
string sAxisType,
float sngBestScaleUnits)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (clsNumber.ReturnPowerOfTen(sngBestScaleUnits) >= 1)
{
if (gsngMultipleFactor == 15 || gsngMultipleFactor == 25)
{
ChartAxis_YDecimalPlaces(
objChart,
sAxisGroup,
sAxisType,
clsNumber.ReturnPowerOfTen(sngBestScaleUnits)
);
}
else
{
ChartAxis_YDecimalPlaces(
objChart,
sAxisGroup,
sAxisType,
clsNumber.ReturnPowerOfTen(sngBestScaleUnits) - 1
);
}
}
else //scale is greater than 10, so no decimal places required
{
ChartAxis_YDecimalPlaces(objChart, sAxisGroup, sAxisType, 0);
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleAlterDecimalPlaces",
msMODULENAME,
"adjust the number of decimal places on the " +
"Axis Group - " + sAxisGroup + ".",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_YScaleAutomatic
public void ChartAxis_YScaleAutomatic(
Excel.Chart objChart,
string sAxisGroup,
string sAxisType,
float sngsmallestvalue,
float snglargestvalue)
{
int iarrayno;
float sngstartscale;
float sngfinishscale;
float sngSmallest;
float sngLargest;
float sngdifference;
float sngBestScaleUnits;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
sngSmallest = clsNumber.SmallestOneSingle(sngsmallestvalue, snglargestvalue);
sngLargest = clsNumber.LargestOneSingle(sngsmallestvalue, snglargestvalue);
sngSmallest = ChartAxis_SmallestAdjustment(sngSmallest, sngLargest);
sngLargest = ChartAxis_LargestAdjustment(sngSmallest, sngLargest);
//calculate the actual difference
sngdifference = Math.Abs(sngLargest - sngSmallest);
sngfinishscale = sngSmallest;
//repeat until the scale is suitable
do
{
Array.Resize(ref giAppScaleMultiple, giDEF_AXISSCALEMAX + 1);
Array.Resize(ref gsngActualScale, giDEF_AXISSCALEMAX + 1);
for (iarrayno = giDEF_AXISSCALEMIN; iarrayno <= giDEF_AXISSCALEMAX; iarrayno++)
{
ChartAxis_YCalculateXLines(iarrayno, sngdifference);
}
//calculates the best scale
sngBestScaleUnits = ChartAxis_YScaleChooseBest();
sngstartscale = ChartAxis_YScaleGetStart(objChart, sngSmallest,
sngBestScaleUnits);
sngfinishscale = ChartAxis_YScaleGetFinish(objChart, sngstartscale,
sngBestScaleUnits);
//increments diff. if not successful
sngdifference = (float)(sngdifference * 1.01);
}
while (sngfinishscale <= sngLargest);
ChartAxis_YScaleDefine(objChart, sAxisGroup, sAxisType,
sngstartscale, sngfinishscale,
sngBestScaleUnits);
ChartAxis_YScaleAlterDecimalPlaces(objChart, sAxisGroup, sAxisType,
sngBestScaleUnits);
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleAutomatic",
msMODULENAME,
"adjust the scales of the axes to the 'RP Automatic' scaling.",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_YScaleChoose
public float ChartAxis_YScaleChoose(
float sngIdealScale)
{
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
if ((10 < sngIdealScale) && (sngIdealScale <= 15))
return 15;
if ((15 < sngIdealScale) && (sngIdealScale <= 20))
return 20;
if ((20 < sngIdealScale) && (sngIdealScale <= 25))
return 25;
if ((25 < sngIdealScale) && (sngIdealScale <= 50))
return 50;
if ((50 < sngIdealScale) && (sngIdealScale <= 100))
return 100;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleChoose",
msMODULENAME,
"choose the best scale for an axis.",
gobjCOMException,
gobjException
);
}
}
return 0;
}
ChartAxis_YScaleChooseBest
public float ChartAxis_YScaleChooseBest(
float sngIdealScale = 0)
{
int iarrayno;
float sngsmallestunit;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
if (sngIdealScale == 0)
{
//max no. of lines first
sngsmallestunit = gsngActualScale[giDEF_AXISSCALEMAX];
//start at maxno. of lines
for (iarrayno = giDEF_AXISSCALEMAX; iarrayno >= giDEF_AXISSCALEMIN; iarrayno--)
{
if (gsngActualScale[iarrayno] <= sngsmallestunit)
{
sngsmallestunit = gsngActualScale[iarrayno];
giNoofLinesChosen = iarrayno;
gsngMultipleFactor = giAppScaleMultiple[iarrayno];
}
}
}
else
{
sngsmallestunit = sngIdealScale;
}
return sngsmallestunit;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleChooseBest",
msMODULENAME,
"choose the best scale for the Y-axis.",
gobjCOMException,
gobjException
);
}
}
return 0;
}
ChartAxis_YScaleDefine
public void ChartAxis_YScaleDefine(
Excel.Chart objChart,
string sAxisGroup,
string sAxisType,
float sngMinimum,
float sngMaximum,
float sngMajorUnit = 0,
string sChartName = "",
string sWshName = "")
{
Excel.Axis objAxis;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objAxis = (Excel.Axis)objChart.Axes(
zReturn_AxisType(sAxisType),
zReturn_AxisGroup(sAxisGroup));
{
var withBlock = objAxis;
withBlock.MinimumScale = sngMinimum;
withBlock.MaximumScale = sngMaximum;
//maybe assign to the minor unit as well - to be sure ???
if (sngMajorUnit > 0)
withBlock.MajorUnit = sngMajorUnit; //assign the new max,min and unit
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objAxis = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleDefine",
msMODULENAME,
"define the scale for the AxisGroup - " + sAxisGroup + ".",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_YScaleGetFinish
public float ChartAxis_YScaleGetFinish(
Excel.Chart objChart,
float sngstartscale,
float sngBestScaleUnits)
{
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
return sngstartscale + (sngBestScaleUnits * giNoofLinesChosen);
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleGetFinish",
msMODULENAME,
"return the calculated largest value for the scale of an axis.",
gobjCOMException,
gobjException
);
}
}
return 0;
}
ChartAxis_YScaleGetStart
public float ChartAxis_YScaleGetStart(
Excel.Chart objChart,
float sngSmallest,
float sngBestScaleUnits)
{
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
if ((sngSmallest == sngBestScaleUnits) || (sngSmallest == 0))
{
return sngSmallest;
}
else if (sngSmallest > 0)
{
return ChartAxes_YScaleAdjustStart(sngSmallest, sngBestScaleUnits);
}
else if (sngSmallest < 0)
{
return -ChartAxes_YScaleAdjustStart(sngSmallest, sngBestScaleUnits);
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleGetStart",
msMODULENAME,
"return the calculated smallest value for for the scale of an axis.",
gobjCOMException,
gobjException
);
}
}
return 0;
}
ChartAxis_YScaleMicrosoft
public void ChartAxis_YScaleMicrosoft(
Excel.Chart objChart,
string sAxisGroup)
{
Excel.Axis objAxis = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (sAxisGroup == "P")
{
objAxis = (Excel.Axis)objChart.Axes(
Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlPrimary);
}
if (sAxisGroup == "S")
{
objAxis = (Excel.Axis)objChart.Axes(
Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlSecondary);
}
if ((sAxisGroup != "P") && (sAxisGroup != "S"))
{
MsgBox("Error - Chart_AxesYScaleMicrosoft");
return;
}
{
var withBlock = objAxis;
withBlock.MinimumScaleIsAuto = true;
withBlock.MaximumScaleIsAuto = true;
withBlock.MinorUnitIsAuto = true;
withBlock.MajorUnitIsAuto = true; //set all the automatic settings to true
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objAxis = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleMicrosoft",
msMODULENAME,
"define the scale for the AxisGroup - " + sAxisGroup +
"to be the \"Microsoft Automatic\" Scaling.",
gobjCOMException,
gobjException
);
}
}
}
ChartAxis_YScaleMicrosoftAlterDecimalPlaces
public void ChartAxis_YScaleMicrosoftAlterDecimalPlaces(
Excel.Chart objChart,
string sAxisGroup,
string sAxisType)
{
Excel.Axis objAxis = null;
float sngscaleunits;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (sAxisGroup == "P")
{
objAxis = (Excel.Axis)objChart.Axes(
Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlPrimary);
}
if (sAxisGroup == "S")
{
objAxis = (Excel.Axis)objChart.Axes(
Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlSecondary);
}
{
var withBlock = objAxis;
sngscaleunits = (float)withBlock.MajorUnit;
}
if (clsNumber.ReturnPowerOfTen(sngscaleunits) >= 1)
{
ChartAxis_YDecimalPlaces(
objChart,
sAxisGroup,
sAxisType,
clsNumber.ReturnPowerOfTen(sngscaleunits) - 1
);
}
else //scale is greater than 10, so no decimal places required
{
ChartAxis_YDecimalPlaces(objChart, sAxisGroup, sAxisType, 0);
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
objAxis = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartAxis_YScaleMicrosoftAlterDecimalPlaces",
msMODULENAME,
"adjust the number of decimal places on the " +
"Axis Group - " + sAxisGroup + ".",
gobjCOMException,
gobjException
);
}
}
}
ChartFormat_ChartArea
public void ChartFormat_ChartArea(
Excel.Chart objChart,
string sFontName = "AR",
float sngFontSize = 10,
int iFontColourIdx = 1,
string sFontBackground = "AU",
bool bBold = false,
bool bItalic = false,
string sUnderline = "NO",
bool bStrikethrough = false,
bool bSubscript = false,
bool bSuperscript = false,
int iBorderColour = 0,
int iBorderWeight = 1,
string sBorderLineStyle = "NO",
bool bShadow = false,
int iInteriorColourIdx = 2,
string sInteriorPatternStyle = "NO",
int iFillForeColour = 1,
int iFillBackColour = 1,
bool bFillAsSolid = true,
string sGradientColourType = "0",
string sGradientStyle = "HR",
int iGradientVariant = 0,
float sngGradientDegree = 0.5f,
string sGradientPresetType = "",
string sTexturePresetType = "NO",
string sFillPatternStyle = "NO")
{
Excel.ChartArea objChartArea = null;
Excel.Font objFont = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objChartArea = objChart.ChartArea;
{
var withBlock = objChartArea;
withBlock.AutoScaleFont = false; //prevents the Not Enough Memory error
objFont = withBlock.Font;
{
var withFont = objFont;
withFont.Name = zReturn_FontName(sFontName);
withFont.Size = sngFontSize;
//.Color =
withFont.ColorIndex = iFontColourIdx;
withFont.Background = zReturn_Background(sFontBackground);
withFont.Bold = bBold;
withFont.Italic = bItalic;
withFont.Shadow = bShadow;
withFont.Underline = zReturn_UnderlineStyle(sUnderline);
withFont.Strikethrough = bStrikethrough;
withFont.Subscript = bSubscript;
withFont.Superscript = bSuperscript;
//.OutlineFont = False Not used on Windows
}
withBlock.Border.Color = iBorderColour;
withBlock.Border.Weight = zReturn_BorderWeight(iBorderWeight);
withBlock.Border.LineStyle = zReturn_LineStyle(sBorderLineStyle);
//chart area has a shadow property
withBlock.Shadow = bShadow;
if ((sInteriorPatternStyle == "NO") &&
(sGradientColourType == "0") &&
(sTexturePresetType == "NO"))
{
withBlock.Fill.Solid();
withBlock.Interior.ColorIndex = iInteriorColourIdx;
}
if (sInteriorPatternStyle != "NO")
{
withBlock.Interior.Pattern = zReturn_Pattern(sInteriorPatternStyle);
}
if (sGradientColourType == "1")
{
//doesn't seem to work ?
//.Fill.ForeColor.RGB = RGB(120, 120, 120)
withBlock.Fill.ForeColor.SchemeColor = iFillForeColour;
withBlock.Fill.OneColorGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant,
Degree: sngGradientDegree
);
}
if ((sGradientColourType == "2") ||
((sInteriorPatternStyle != "NO") && (sGradientColourType == "0")))
{
withBlock.Fill.ForeColor.SchemeColor = iFillForeColour;
withBlock.Fill.BackColor.SchemeColor = iFillBackColour;
withBlock.Fill.TwoColorGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant
);
}
if (sGradientColourType == "P")
{
withBlock.Fill.PresetGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant,
PresetGradientType: zReturn_PresetGradientType(sGradientPresetType)
);
}
if (sTexturePresetType != "NO")
{
withBlock.Fill.PresetTextured(
PresetTexture: zReturn_PresetTextureType(sTexturePresetType)
);
}
if (sFillPatternStyle != "NO")
{
withBlock.Fill.Patterned(
Pattern: zReturn_PatternType(sFillPatternStyle)
);
}
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
objChartArea = null;
objFont = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartFormat_ChartArea",
msMODULENAME,
"format the chart area on the active chart.",
gobjCOMException,
gobjException
);
}
}
}
ChartFormat_DataTableSizePosition
public void ChartFormat_DataTableSizePosition(
Excel.Chart objChart,
float sngFontSize = 10)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
{
var withBlock = objChart;
//-----------------
if (withBlock.HasDataTable == true)
{
// .DataTable = bHasADataTable
}
//.DataTable.Delete
}
//ensure fonts are correct after re-sizing
objChart.ChartArea.Font.Size = sngFontSize;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"Chart_DataTableSizePosition",
msMODULENAME,
"adjust the size and position of the data table.",
gobjCOMException,
gobjException
);
}
}
}
ChartFormat_Legend
public void ChartFormat_Legend(
Excel.Chart objChart,
string sFontName = "AR",
float sngFontSize = 10,
int iFontColourIdx = 1,
string sFontBackground = "AU",
bool bBold = false,
bool bItalic = false,
bool bUnderLine = false,
bool bStrikethrough = false,
bool bSubscript = false,
bool bSuperscript = false,
int iBorderColour = 1,
int iBorderWeight = 1,
string sBorderLineStyle = "NO",
bool bShadow = false,
int iInteriorColourIdx = 2,
string sInteriorPatternStyle = "NO",
int iFillForeColour = 0,
int iFillBackColour = 0,
bool bFillAsSolid = true,
string sGradientColourType = "0",
string sGradientStyle = "HR",
int iGradientVariant = 1,
float sngGradientDegree = 0.5f,
string sGradientPresetType = "",
string sTexturePresetType = "NO",
string sFillPatternStyle = "NO")
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (objChart.HasLegend == true)
{
var withLegend = objChart.Legend;
{
var withFont = withLegend.Font;
withFont.Name = zReturn_FontName(sFontName);
withFont.Size = sngFontSize;
//.Color
withFont.ColorIndex = iFontColourIdx;
withFont.Background = zReturn_Background(sFontBackground);
withFont.Bold = bBold;
withFont.Italic = bItalic;
withFont.Shadow = bShadow;
withFont.Underline = bUnderLine;
withFont.Strikethrough = bStrikethrough;
withFont.Subscript = bSubscript;
withFont.Superscript = bSuperscript;
}
withLegend.Border.Color = iBorderColour;
withLegend.Border.Weight = zReturn_BorderWeight(iBorderWeight);
withLegend.Border.LineStyle = zReturn_LineStyle(sBorderLineStyle);
withLegend.Shadow = bShadow;
if ((sTexturePresetType == "NO") &&
(sGradientColourType == "0") &&
(sInteriorPatternStyle == "NO"))
{
withLegend.Fill.Solid();
withLegend.Interior.ColorIndex = iInteriorColourIdx;
}
if (sInteriorPatternStyle != "NO")
{
withLegend.Interior.Pattern = zReturn_Pattern(sInteriorPatternStyle);
}
if (sGradientColourType == "1")
{
withLegend.Fill.ForeColor.SchemeColor = iFillForeColour;
}
if ((sGradientColourType == "2") ||
((sInteriorPatternStyle != "NO") && (sGradientColourType == "0")))
{
withLegend.Fill.ForeColor.SchemeColor = iFillForeColour;
withLegend.Fill.BackColor.SchemeColor = iFillBackColour;
}
if (sGradientColourType == "1")
{
withLegend.Fill.OneColorGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant,
Degree: sngGradientDegree
);
}
if (sGradientColourType == "2")
{
withLegend.Fill.TwoColorGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant
);
}
if (sGradientColourType == "P")
{
withLegend.Fill.PresetGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant,
PresetGradientType: zReturn_PresetGradientType(sGradientPresetType)
);
}
if (sTexturePresetType != "NO")
{
withLegend.Fill.PresetTextured(
PresetTexture: zReturn_PresetTextureType(sTexturePresetType)
);
}
if (sFillPatternStyle != "NO")
{
withLegend.Fill.Patterned(
Pattern: zReturn_PatternType(sFillPatternStyle)
);
}
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"Chart_LegendFormat",
msMODULENAME,
"format the legend on the active chart.",
gobjCOMException,
gobjException
);
}
}
}
ChartFormat_LegendSizePosition
public void ChartFormat_LegendSizePosition(
Excel.Chart objChart,
string sLegendPositionKey = "BT",
float sngFontSize = 10)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
{
var withBlock = objChart;
//------------------
if (withBlock.HasLegend == true)
{
withBlock.Legend.Position = zReturn_LegendPosition(sLegendPositionKey);
withBlock.PlotArea.Height = withBlock.ChartArea.Height;
if (sLegendPositionKey == "BT")
{
//if the legend is at the bottom then move plot area up
withBlock.PlotArea.Height = withBlock.PlotArea.Height - withBlock.Legend.Height;
withBlock.Legend.Left = withBlock.ChartArea.Left;
withBlock.Legend.Width = withBlock.ChartArea.Width;
}
if (sLegendPositionKey == "RI")
{
//if the legend is at the bottom then move plot area up
withBlock.PlotArea.Height = withBlock.PlotArea.Height - withBlock.Legend.Height;
withBlock.Legend.Left = withBlock.ChartArea.Left + withBlock.ChartArea.Width;
//the minus 1 is needed as it chops off the bottom of the legend otherwise
withBlock.Legend.Height = (withBlock.ChartArea.Height - 6);
}
}
}
//ensure fonts are correct after re-sizing
objChart.ChartArea.Font.Size = sngFontSize;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"Chart_LegendSizePosition",
msMODULENAME,
"adjust the size and position of the legend.",
gobjCOMException,
gobjException
);
}
}
}
ChartFormat_PlotArea
public void ChartFormat_PlotArea(
Excel.Chart objChart,
int iBorderColour = 0,
int iBorderWeight = 1,
string sBorderLineStyle = "NO",
int iInteriorColourIdx = 2,
string sInteriorPatternStyle = "NO",
int iFillForeColour = 0,
int iFillBackColour = 0,
bool bFillAsSolid = true,
string sGradientColourType = "0",
string sGradientStyle = "HR",
int iGradientVariant = 1,
float sngGradientDegree = 0.5f,
string sGradientPresetType = "",
string sTexturePresetType = "NO",
string sFillPatternStyle = "NO")
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
var withBlock = objChart.PlotArea;
withBlock.Border.Color = iBorderColour;
withBlock.Border.Weight = zReturn_BorderWeight(iBorderWeight);
withBlock.Border.LineStyle = zReturn_LineStyle(sBorderLineStyle);
// ---------------- plot area doesn't have a shadow !!
if ((sTexturePresetType == "NO") &&
(sGradientColourType == "0") &&
(sInteriorPatternStyle == "NO"))
{
withBlock.Fill.Solid();
withBlock.Interior.ColorIndex = iInteriorColourIdx;
}
if (sInteriorPatternStyle != "NO")
{
withBlock.Interior.Pattern = zReturn_Pattern(sInteriorPatternStyle);
}
if (sGradientColourType == "1")
{
withBlock.Fill.ForeColor.SchemeColor = iFillForeColour;
}
if ((sGradientColourType == "2") ||
((sInteriorPatternStyle != "NO") && (sGradientColourType == "0")))
{
withBlock.Fill.ForeColor.SchemeColor = iFillForeColour;
withBlock.Fill.BackColor.SchemeColor = iFillBackColour;
}
if (sGradientColourType == "1")
{
withBlock.Fill.OneColorGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant,
Degree: sngGradientDegree
);
}
if (sGradientColourType == "2")
{
withBlock.Fill.TwoColorGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant
);
}
if (sGradientColourType == "P")
{
withBlock.Fill.PresetGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant,
PresetGradientType: zReturn_PresetGradientType(sGradientPresetType)
);
}
if (sTexturePresetType != "NO")
{
withBlock.Fill.PresetTextured(
PresetTexture: zReturn_PresetTextureType(sTexturePresetType)
);
}
if (sFillPatternStyle != "NO")
{
withBlock.Fill.Patterned(
Pattern: zReturn_PatternType(sFillPatternStyle)
);
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"Chart_PlotAreaFormat",
msMODULENAME,
"format the plot area on the active chart.",
gobjCOMException,
gobjException
);
}
}
}
ChartFormat_PlotAreaSizeMove
public void ChartFormat_PlotAreaSizeMove(
Excel.Chart objChart,
double dbWidth,
int iFromLeft,
double dbHeight,
int iFromTop,
string sChartName = "",
string sWshName = "")
{
Excel.PlotArea objPlotArea = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
//maybe split in 2 separate procedures
objPlotArea = objChart.PlotArea;
{
var withBlock = objPlotArea; //all these widths are in points !!
withBlock.Left = iFromLeft;
withBlock.Width = dbWidth; //Application.UsableWidth ???
withBlock.Top = iFromTop;
withBlock.Height = dbHeight; //Application.UsableHeight ???
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
objPlotArea = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"Chart_PlotAreaSizeMove",
msMODULENAME,
"adjust the size and positioning of the plot area on the active chart.",
gobjCOMException,
gobjException
);
}
}
}
ChartFormat_SeriesArea
public void ChartFormat_SeriesArea(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo,
string sSeriesName = "",
int iBorderColour = 0,
int iBorderWeight = 1,
string sBorderLineStyle = "NO",
int iInteriorColourIdx = 0,
string sInteriorPatternStyle = "NO",
int iFillForeColour = 0,
int iFillBackColour = 0,
bool bFillAsSolid = true,
string sGradientColourType = "0",
string sGradientStyle = "HR",
int iGradientVariant = 1,
float sngGradientDegree = 0.5f,
string sGradientPresetType = "",
string sTexturePresetType = "NO",
string sFillPatternStyle = "NO")
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (sSeriesName != "")
objSeries.Name = sSeriesName;
{
var withBlock = objSeries;
withBlock.Border.Color = iBorderColour;
withBlock.Border.Weight = zReturn_BorderWeight(iBorderWeight);
withBlock.Border.LineStyle = zReturn_LineStyle(sBorderLineStyle);
if ((sTexturePresetType == "NO") &&
(sGradientColourType == "0") &&
(sInteriorPatternStyle == "NO"))
{
withBlock.Fill.Solid();
if (iInteriorColourIdx == 0)
{
withBlock.Interior.ColorIndex = Colour_AreaReturn(iSeriesNo);
withBlock.Interior.Pattern = Excel.XlPattern.xlPatternSolid;
}
if (iInteriorColourIdx > 0)
{
withBlock.Interior.ColorIndex = iInteriorColourIdx;
withBlock.Interior.Pattern = Excel.XlPattern.xlPatternSolid;
}
}
if (sInteriorPatternStyle != "NO")
{
withBlock.Interior.Pattern = zReturn_Pattern(sInteriorPatternStyle);
}
if (sGradientColourType == "1")
{
if (iFillForeColour == 0)
withBlock.Fill.ForeColor.SchemeColor = 16 + iSeriesNo;
if (iFillForeColour != 0)
withBlock.Fill.ForeColor.SchemeColor = 16 + iSeriesNo;
}
if ((sGradientColourType == "2") ||
((sInteriorPatternStyle != "NO") && (sGradientColourType == "0")))
{
if (iFillForeColour == 0)
withBlock.Fill.ForeColor.SchemeColor = 16 + iSeriesNo;
if (iFillForeColour != 0)
withBlock.Fill.ForeColor.SchemeColor = 16 + iSeriesNo;
withBlock.Fill.BackColor.SchemeColor = 16 + iSeriesNo;
}
if (sGradientColourType == "1")
{
withBlock.Fill.OneColorGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant,
Degree: sngGradientDegree
);
}
if (sGradientColourType == "2")
{
withBlock.Fill.TwoColorGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant
);
}
if (sGradientColourType == "P")
{
withBlock.Fill.PresetGradient(
Style: zReturn_GradientStyle(sGradientStyle),
Variant: iGradientVariant,
PresetGradientType: zReturn_PresetGradientType(sGradientPresetType)
);
}
if (sTexturePresetType != "NO")
{
withBlock.Fill.PresetTextured(
PresetTexture: zReturn_PresetTextureType(sTexturePresetType)
);
}
if (sFillPatternStyle != "NO")
{
withBlock.Fill.Patterned(
Pattern: zReturn_PatternType(sFillPatternStyle)
);
}
}
if (ChartType_SeriesTypeIsIt3D(objSeries) == true)
{
Chart_SeriesFormat3D(objChart, objSeries, iSeriesNo);
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"Chart_SeriesAreaFormat",
msMODULENAME,
"format the 'Area' of the chart.",
gobjCOMException,
gobjException
);
}
}
}
ChartFormat_SeriesLine
public void ChartFormat_SeriesLine(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo,
string sSeriesName = "")
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (sSeriesName != "")
{
objSeries.Name = sSeriesName;
}
{
var withBlock = objSeries;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"Chart_SeriesLineFormat",
msMODULENAME,
"format the 'Line' of the chart.",
gobjCOMException,
gobjException
);
}
}
}
ChartFormat_TitleSizePosition
public void ChartFormat_TitleSizePosition(
Excel.Chart objChart,
string sLegendPositionKey = "BT",
float sngFontSize = 10)
{
Excel.ChartArea objChartArea = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objChartArea = objChart.ChartArea;
{
var withBlock = objChart;
//------------------
if (withBlock.HasTitle == true)
{
withBlock.ChartTitle.Top = 1; //if there is a title put it at the top
withBlock.ChartTitle.Left =
(objChartArea.Width -
(Microsoft.VisualBasic.Strings.Len(withBlock.ChartTitle.Characters.Text) * 3)) / 2;
// .ChartTitle.Left = in the middle - needs to be in the middle ???????
withBlock.PlotArea.Height = withBlock.PlotArea.Height - giDEF_TITLESPACE;
//height + top must always be the same !!
withBlock.PlotArea.Top = withBlock.PlotArea.Top + giDEF_TITLESPACE;
}
}
objChartArea.Font.Size = sngFontSize; //ensure fonts are correct after re-sizing
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
objChartArea = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"Chart_TitleSizePosition",
msMODULENAME,
"adjust the size and position of the title.",
gobjCOMException,
gobjException
);
}
}
}
ChartHas_Legend
public static bool ChartHas_Legend(
Excel.Chart objChart)
{
try
{
// an error occurs then there is no plot area
if (objChart.Legend.Border.Color == 0)
ChartHasLegend = true;
}
catch (Runtime.InteropServices.COMException objCOMException)
{
ChartHasLegend = false;
}
}
ChartHas_PlotArea
public static bool ChartHas_PlotArea(
Excel.Chart objChart)
{
try
{
// an error occurs then there is no plot area
if (objChart.PlotArea.Border.Color == 0)
{
}
ChartHas_PlotArea = true;
}
catch (Runtime.InteropServices.COMException objCOMException)
{
ChartHasPlotArea = false;
}
}
ChartHas_SeriesCollection
public static bool ChartHas_SeriesCollection(
Excel.SeriesCollection objSeriesColl,
System.Int32 iSeriesNo)
{
try
{
// an error occurs when the series number is valid but not plotted - eg Pie Charts
Excel.Series objSeries;
objSeries = objSeriesColl.Item(iSeriesNo);
ChartSeriesExists = true;
}
catch (Runtime.InteropServices.COMException objCOMException)
{
ChartSeriesExists = false;
}
}
ChartReturns_3DBarShape
public Excel.XlBarShape ChartReturns_3DBarShape(
string sBarShapeKey)
{
Excel.XlBarShape objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sBarShapeKey)
{
case "BX":
objtemp = Excel.XlBarShape.xlBox;
break;
case "CTM":
objtemp = Excel.XlBarShape.xlConeToMax;
break;
case "CTP":
objtemp = Excel.XlBarShape.xlConeToPoint;
break;
case "CY":
objtemp = Excel.XlBarShape.xlCylinder;
break;
case "PTM":
objtemp = Excel.XlBarShape.xlPyramidToMax;
break;
case "PTP":
objtemp = Excel.XlBarShape.xlPyramidToPoint;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Border Weight abbreviation : " + sBarShapeKey,
"ChartReturns_3DBarShape"
);
break;
}
ChartReturns_3DBarShape = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_3DBarShape",
msMODULENAME,
"return the corresponding 3D shape for the abbreviation '" +
sBarShapeKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_3DBarShape;
}
ChartReturns_AxisCategoryType
public Excel.XlCategoryType ChartReturns_AxisCategoryType(
string sAxisCategoryTypeKey)
{
Excel.XlCategoryType objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sAxisCategoryTypeKey)
{
case "CA":
objtemp = Excel.XlCategoryType.xlCategoryScale;
break;
case "TS":
objtemp = Excel.XlCategoryType.xlTimeScale;
break;
case "AS":
objtemp = Excel.XlCategoryType.xlAutomaticScale;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Axis Category Type abbreviation : " + sAxisCategoryTypeKey,
"ChartReturns_AxesCategoryType"
);
break;
}
ChartReturns_AxisCategoryType = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_AxesCategoryType",
msMODULENAME,
"return the corresponding axis category type for the abbreviation '" +
sAxisCategoryTypeKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_AxisCategoryType;
}
ChartReturns_AxisGroup
public Excel.XlAxisGroup ChartReturns_AxisGroup(
string sAxisGroupKey)
{
Excel.XlAxisGroup objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sAxisGroupKey)
{
case "P":
objtemp = Excel.XlAxisGroup.xlPrimary;
break;
case "S":
objtemp = Excel.XlAxisGroup.xlSecondary;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Axis Group abbreviation : " + sAxisGroupKey,
"ChartReturns_AxesGroup"
);
break;
}
ChartReturns_AxisGroup = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_AxisGroup",
msMODULENAME,
"return the corresponding axis group for the abbreviation '" +
sAxisGroupKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_AxisGroup;
}
ChartReturns_AxisType
public Excel.XlAxisType ChartReturns_AxisType(
string sAxisTypeKey)
{
Excel.XlAxisType objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sAxisTypeKey)
{
case "V":
objtemp = Excel.XlAxisType.xlValue; // the y-axis
break;
case "C":
objtemp = Excel.XlAxisType.xlCategory; // the x-axis
break;
case "S":
objtemp = Excel.XlAxisType.xlSeriesAxis; // only for 3D charts
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Axis Type abbreviation : " + sAxisTypeKey,
"ChartReturns_AxisType"
);
break;
}
ChartReturns_AxisType = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_AxisType",
msMODULENAME,
"return the corresponding axis type for the abbreviation '" +
sAxisTypeKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_AxisType;
}
ChartReturns_Background
public Excel.XlBackground ChartReturns_Background(
string sBackgroundKey)
{
Excel.XlBackground objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sBackgroundKey)
{
case "AU":
objtemp = Excel.XlBackground.xlBackgroundAutomatic;
break;
case "OP":
objtemp = Excel.XlBackground.xlBackgroundOpaque;
break;
case "TR":
objtemp = Excel.XlBackground.xlBackgroundTransparent;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Background abbreviation : " + sBackgroundKey,
"ChartReturns_BackgroundType"
);
break;
}
ChartReturns_Background = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_Background",
msMODULENAME,
"return the corresponding background type for the abbreviation '" +
sBackgroundKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_Background;
}
ChartReturns_BorderWeight
public Excel.XlBorderWeight ChartReturns_BorderWeight(
int sBorderWeightKey)
{
Excel.XlBorderWeight objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sBorderWeightKey)
{
case 1:
objtemp = Excel.XlBorderWeight.xlHairline;
break;
case 2:
objtemp = Excel.XlBorderWeight.xlThin;
break;
case 3:
objtemp = Excel.XlBorderWeight.xlMedium;
break;
case 4:
objtemp = Excel.XlBorderWeight.xlThick;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Border Weight number : " + sBorderWeightKey,
"ChartReturns_BorderWeight"
);
break;
}
ChartReturns_BorderWeight = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_BorderWeight",
msMODULENAME,
"return the corresponding border weight for the abbreviation '" +
sBorderWeightKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_BorderWeight;
}
ChartReturns_DataLabelPosition
public Excel.XlDataLabelPosition ChartReturns_DataLabelPosition(
string sDataLabelPosKey)
{
Excel.XlDataLabelPosition objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sDataLabelPosKey)
{
case "AB":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionAbove;
break;
case "BL":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionBelow;
break;
case "BF":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionBestFit;
break;
case "CT":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionCenter;
break;
case "CU":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionCustom;
break;
case "IB":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionInsideBase;
break;
case "IE":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionInsideEnd;
break;
case "LF":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionLeft;
break;
case "MX":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionMixed;
break;
case "OE":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionOutsideEnd;
break;
case "RI":
objtemp = Excel.XlDataLabelPosition.xlLabelPositionRight;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Data Label Position abbreviation : " + sDataLabelPosKey,
"ChartReturns_DataLabelPosition"
);
break;
}
ChartReturns_DataLabelPosition = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_DataLabelPosition",
msMODULENAME,
"return the corresponding data label position for the abbreviation '" +
sDataLabelPosKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_DataLabelPosition;
}
ChartReturns_DataLabelsType
public Excel.XlDataLabelsType ChartReturns_DataLabelsType(
string sDataLabelTypeKey)
{
Excel.XlDataLabelsType objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sDataLabelTypeKey)
{
case "NO":
objtemp = Excel.XlDataLabelsType.xlDataLabelsShowNone;
break;
case "VA":
objtemp = Excel.XlDataLabelsType.xlDataLabelsShowValue;
break;
case "PC":
objtemp = Excel.XlDataLabelsType.xlDataLabelsShowPercent;
break;
case "LB":
objtemp = Excel.XlDataLabelsType.xlDataLabelsShowLabel;
break;
case "LBPC":
objtemp = Excel.XlDataLabelsType.xlDataLabelsShowLabelAndPercent;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Data Label Type abbreviation : " + sDataLabelTypeKey,
"ChartReturns_DataLabelPosition"
);
break;
}
ChartReturns_DataLabelsType = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_DataLabelsType",
msMODULENAME,
"return the corresponding data label type for the abbreviation '" +
sDataLabelTypeKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_DataLabelsType;
}
ChartReturns_FontName
public string ChartReturns_FontName(
string sFontNameKey)
{
try
{
if (clsError.ErrorFlag() == true)
{
return null;
}
string stemp;
if (string.IsNullOrEmpty(sFontNameKey))
sFontNameKey = "AR";
switch (sFontNameKey)
{
case "UN":
stemp = "UniversLight";
break;
case "AR":
stemp = "Arial";
break;
case "HL":
stemp = "Helvetica";
break;
case "TN":
stemp = "Times New Roman";
break;
case "AN":
stemp = "ArialNarrow";
break;
case "AB":
stemp = "Arial Black";
break;
case "SB":
stemp = "Sabon";
break;
case "MS":
stemp = "Monotype sorts";
break;
case "VB":
stemp = "VeticaBlack";
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Font Name abbreviation : " + sFontNameKey,
"ChartReturns_FontName"
);
stemp = null;
break;
}
ChartReturns_FontName = stemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_FontName",
msMODULENAME,
"return the corresponding font name for the abbreviation '" +
sFontNameKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_FontName;
}
ChartReturns_GradientStyle
public Office.MsoGradientStyle ChartReturns_GradientStyle(
string sGradientStyleKey)
{
Office.MsoGradientStyle objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sGradientStyleKey)
{
case "DDW":
objtemp = Office.MsoGradientStyle.msoGradientDiagonalDown;
break;
case "DUP":
objtemp = Office.MsoGradientStyle.msoGradientDiagonalUp;
break;
case "FCE":
objtemp = Office.MsoGradientStyle.msoGradientFromCenter;
break;
case "FCR":
objtemp = Office.MsoGradientStyle.msoGradientFromCorner;
break;
case "HR":
objtemp = Office.MsoGradientStyle.msoGradientHorizontal;
break;
case "VR":
objtemp = Office.MsoGradientStyle.msoGradientVertical;
break;
case "MX":
objtemp = Office.MsoGradientStyle.msoGradientMixed;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Gradient Style abbreviation : " + sGradientStyleKey,
"ChartReturns_GradientStyle"
);
break;
}
ChartReturns_GradientStyle = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_GradientStyle",
msMODULENAME,
"return the corresponding gradient style for the abbreviation '" +
sGradientStyleKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_GradientStyle;
}
ChartReturns_LegendPosition
public Excel.XlLegendPosition ChartReturns_LegendPosition(
string sLegendPositionKey)
{
Excel.XlLegendPosition objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sLegendPositionKey)
{
case "TP":
objtemp = Excel.XlLegendPosition.xlLegendPositionTop;
break;
case "BT":
objtemp = Excel.XlLegendPosition.xlLegendPositionBottom;
break;
case "RI":
objtemp = Excel.XlLegendPosition.xlLegendPositionRight;
break;
case "LF":
objtemp = Excel.XlLegendPosition.xlLegendPositionLeft;
break;
case "CR":
objtemp = Excel.XlLegendPosition.xlLegendPositionCorner;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Legend Position abbreviation : " + sLegendPositionKey,
"ChartReturns_LegendPosition"
);
break;
}
ChartReturns_LegendPosition = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_LegendPosition",
msMODULENAME,
"return the corresponding legend position for the abbreviation '" +
sLegendPositionKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_LegendPosition;
}
ChartReturns_LineStyle
public Excel.XlLineStyle ChartReturns_LineStyle(
string sLineStyleKey)
{
Excel.XlLineStyle objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sLineStyleKey)
{
case "NO":
objtemp = Excel.XlLineStyle.xlLineStyleNone; // xlNone
break;
case "CT":
objtemp = Excel.XlLineStyle.xlContinuous;
break;
case "DS":
objtemp = Excel.XlLineStyle.xlDash;
break;
case "DT":
objtemp = Excel.XlLineStyle.xlDot;
break;
case "DDT":
objtemp = Excel.XlLineStyle.xlDashDot;
break;
case "DDD":
objtemp = Excel.XlLineStyle.xlDashDotDot;
break;
case "DBL":
objtemp = Excel.XlLineStyle.xlDouble;
break;
case "SDD":
objtemp = Excel.XlLineStyle.xlSlantDashDot;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Line Style : " + sLineStyleKey,
"ChartReturns_LineStyle"
);
break;
}
ChartReturns_LineStyle = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_LineStyle",
msMODULENAME,
"return the corresponding line style for the abbreviation '" +
sLineStyleKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_LineStyle;
}
ChartReturns_MarkerStyle
public Excel.XlMarkerStyle ChartReturns_MarkerStyle(
string sMarkerStyleKey)
{
Excel.XlMarkerStyle objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sMarkerStyleKey)
{
case "NO":
objtemp = Excel.XlMarkerStyle.xlMarkerStyleNone;
break;
case "AU":
objtemp = Excel.XlMarkerStyle.xlMarkerStyleAutomatic;
break;
case "SQ":
objtemp = Excel.XlMarkerStyle.xlMarkerStyleSquare;
break;
case "DI":
objtemp = Excel.XlMarkerStyle.xlMarkerStyleDiamond;
break;
case "TR":
objtemp = Excel.XlMarkerStyle.xlMarkerStyleTriangle;
break;
case "XX":
objtemp = Excel.XlMarkerStyle.xlMarkerStyleX;
break;
case "ST":
objtemp = Excel.XlMarkerStyle.xlMarkerStyleStar;
break;
case "DT":
objtemp = Excel.XlMarkerStyle.xlMarkerStyleDot;
break;
case "DS":
objtemp = Excel.XlMarkerStyle.xlMarkerStyleDash;
break;
case "CR":
objtemp = Excel.XlMarkerStyle.xlMarkerStyleCircle;
break;
case "PL":
objtemp = Excel.XlMarkerStyle.xlMarkerStylePlus;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Marker Style abbreviation : " + sMarkerStyleKey,
"ChartReturns_MarkerStyle"
);
break;
}
ChartReturns_MarkerStyle = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_MarkerStyle",
msMODULENAME,
"return the corresponding marker style for the abbreviation '" +
sMarkerStyleKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_MarkerStyle;
}
ChartReturns_Pattern
public Excel.XlPattern ChartReturns_Pattern(
string sPatternKey)
{
Excel.XlPattern objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sPatternKey)
{
case "NO":
objtemp = Excel.XlPattern.xlPatternNone;
break;
case "SLD":
case "SD":
objtemp = Excel.XlPattern.xlPatternSolid;
break;
case "AU":
objtemp = Excel.XlPattern.xlPatternAutomatic;
break;
case "CH":
objtemp = Excel.XlPattern.xlPatternChecker;
break;
case "CC":
objtemp = Excel.XlPattern.xlPatternCrissCross;
break;
case "G16":
objtemp = Excel.XlPattern.xlPatternGray16;
break;
case "G25":
objtemp = Excel.XlPattern.xlPatternGray25;
break;
case "G50":
objtemp = Excel.XlPattern.xlPatternGray50;
break;
case "G75":
objtemp = Excel.XlPattern.xlPatternGray75;
break;
case "G8":
objtemp = Excel.XlPattern.xlPatternGray8;
break;
case "GR":
objtemp = Excel.XlPattern.xlPatternGrid;
break;
case "UP":
objtemp = Excel.XlPattern.xlPatternUp;
break;
case "DN":
objtemp = Excel.XlPattern.xlPatternDown;
break;
case "HR":
objtemp = Excel.XlPattern.xlPatternHorizontal;
break;
case "VT":
objtemp = Excel.XlPattern.xlPatternVertical;
break;
case "LU":
objtemp = Excel.XlPattern.xlPatternLightUp;
break;
case "LD":
objtemp = Excel.XlPattern.xlPatternLightDown;
break;
case "LH":
objtemp = Excel.XlPattern.xlPatternLightHorizontal;
break;
case "LV":
objtemp = Excel.XlPattern.xlPatternLightVertical;
break;
case "SG75":
objtemp = Excel.XlPattern.xlPatternSemiGray75;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Pattern Style abbreviation : " + sPatternKey,
"ChartReturns_Pattern"
);
break;
}
ChartReturns_Pattern = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_Pattern",
msMODULENAME,
"return the corresponding pattern for the abbreviation '" +
sPatternKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_Pattern;
}
ChartReturns_PatternType
public Office.MsoPatternType ChartReturns_PatternType(
string sPatternTypeKey)
{
Office.MsoPatternType objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sPatternTypeKey)
{
case "5P": objtemp = Office.MsoPatternType.msoPattern5Percent; break;
case "10P": objtemp = Office.MsoPatternType.msoPattern10Percent; break;
case "20P": objtemp = Office.MsoPatternType.msoPattern20Percent; break;
case "25P": objtemp = Office.MsoPatternType.msoPattern25Percent; break;
case "30P": objtemp = Office.MsoPatternType.msoPattern30Percent; break;
case "40P": objtemp = Office.MsoPatternType.msoPattern40Percent; break;
case "50P": objtemp = Office.MsoPatternType.msoPattern50Percent; break;
case "60P": objtemp = Office.MsoPatternType.msoPattern60Percent; break;
case "70P": objtemp = Office.MsoPatternType.msoPattern70Percent; break;
case "75P": objtemp = Office.MsoPatternType.msoPattern75Percent; break;
case "80P": objtemp = Office.MsoPatternType.msoPattern80Percent; break;
case "90P": objtemp = Office.MsoPatternType.msoPattern90Percent; break;
case "DRKDWDI": objtemp = Office.MsoPatternType.msoPatternDarkDownwardDiagonal; break;
case "LHTDWDI": objtemp = Office.MsoPatternType.msoPatternLightDownwardDiagonal; break;
case "WDEDWDI": objtemp = Office.MsoPatternType.msoPatternWideDownwardDiagonal; break;
case "DSHDWDI": objtemp = Office.MsoPatternType.msoPatternDashedDownwardDiagonal; break;
case "DRKUPDI": objtemp = Office.MsoPatternType.msoPatternDarkUpwardDiagonal; break;
case "LHTUPDI": objtemp = Office.MsoPatternType.msoPatternLightUpwardDiagonal; break;
case "WDEUPDI": objtemp = Office.MsoPatternType.msoPatternWideUpwardDiagonal; break;
case "DSHUPDI": objtemp = Office.MsoPatternType.msoPatternDashedUpwardDiagonal; break;
case "DRKHR": objtemp = Office.MsoPatternType.msoPatternDarkHorizontal; break;
case "LHTHR": objtemp = Office.MsoPatternType.msoPatternLightHorizontal; break;
case "NRWHR": objtemp = Office.MsoPatternType.msoPatternNarrowHorizontal; break;
case "DRKVR": objtemp = Office.MsoPatternType.msoPatternDarkVertical; break;
case "LHTVR": objtemp = Office.MsoPatternType.msoPatternLightVertical; break;
case "NRWVR": objtemp = Office.MsoPatternType.msoPatternNarrowVertical; break;
case "DSHVR": objtemp = Office.MsoPatternType.msoPatternDashedVertical; break;
case "DSHHR": objtemp = Office.MsoPatternType.msoPatternDashedHorizontal; break;
case "DIABR": objtemp = Office.MsoPatternType.msoPatternDiagonalBrick; break;
case "DTDGR": objtemp = Office.MsoPatternType.msoPatternDottedGrid; break;
case "HRBR": objtemp = Office.MsoPatternType.msoPatternHorizontalBrick; break;
case "LRGCHBD": objtemp = Office.MsoPatternType.msoPatternLargeCheckerBoard; break;
case "SMLCHBD": objtemp = Office.MsoPatternType.msoPatternSmallCheckerBoard; break;
case "LRGCON": objtemp = Office.MsoPatternType.msoPatternLargeConfetti; break;
case "SMLCON": objtemp = Office.MsoPatternType.msoPatternSmallConfetti; break;
case "LRGGR": objtemp = Office.MsoPatternType.msoPatternLargeGrid; break;
case "SMLGR": objtemp = Office.MsoPatternType.msoPatternSmallGrid; break;
case "MX": objtemp = Office.MsoPatternType.msoPatternMixed; break;
case "TR": objtemp = Office.MsoPatternType.msoPatternTrellis; break;
case "WE": objtemp = Office.MsoPatternType.msoPatternWeave; break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Pattern Style abbreviation : " + sPatternTypeKey,
"ChartReturns_PatternStyle"
);
break;
}
ChartReturns_PatternType = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_PatternType",
msMODULENAME,
"return the corresponding pattern type for the abbreviation '" +
sPatternTypeKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_PatternType;
}
ChartReturns_PresetGradientType
public Office.MsoPresetGradientType ChartReturns_PresetGradientType(
string sPresetGradientStyleKey)
{
Office.MsoPresetGradientType objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sPresetGradientStyleKey)
{
case "BRS": objtemp = Office.MsoPresetGradientType.msoGradientBrass; break;
case "CLM": objtemp = Office.MsoPresetGradientType.msoGradientCalmWater; break;
case "CHR": objtemp = Office.MsoPresetGradientType.msoGradientChrome; break;
case "CHR2": objtemp = Office.MsoPresetGradientType.msoGradientChromeII; break;
case "DYB": objtemp = Office.MsoPresetGradientType.msoGradientDaybreak; break;
case "DES": objtemp = Office.MsoPresetGradientType.msoGradientDesert; break;
case "ESS": objtemp = Office.MsoPresetGradientType.msoGradientEarlySunset; break;
case "FIR": objtemp = Office.MsoPresetGradientType.msoGradientFire; break;
case "FOG": objtemp = Office.MsoPresetGradientType.msoGradientFog; break;
case "GLD": objtemp = Office.MsoPresetGradientType.msoGradientGold; break;
case "GLD2": objtemp = Office.MsoPresetGradientType.msoGradientGoldII; break;
case "HR": objtemp = Office.MsoPresetGradientType.msoGradientHorizon; break;
case "LSS": objtemp = Office.MsoPresetGradientType.msoGradientLateSunset; break;
case "MAH": objtemp = Office.MsoPresetGradientType.msoGradientMahogany; break;
case "MOS": objtemp = Office.MsoPresetGradientType.msoGradientMoss; break;
case "NFL": objtemp = Office.MsoPresetGradientType.msoGradientNightfall; break;
case "OCN": objtemp = Office.MsoPresetGradientType.msoGradientOcean; break;
case "PAR": objtemp = Office.MsoPresetGradientType.msoGradientParchment; break;
case "PCK": objtemp = Office.MsoPresetGradientType.msoGradientPeacock; break;
case "RNB": objtemp = Office.MsoPresetGradientType.msoGradientRainbow; break;
case "RNB2": objtemp = Office.MsoPresetGradientType.msoGradientRainbowII; break;
case "SAP": objtemp = Office.MsoPresetGradientType.msoGradientSapphire; break;
case "SLV": objtemp = Office.MsoPresetGradientType.msoGradientSilver; break;
case "WHT": objtemp = Office.MsoPresetGradientType.msoGradientWheat; break;
case "MX": objtemp = Office.MsoPresetGradientType.msoPresetGradientMixed; break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Gradient Style abbreviation : " + sPresetGradientStyleKey,
"ChartReturns_PresetGradientType"
);
break;
}
ChartReturns_PresetGradientType = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_GradientType",
msMODULENAME,
"return the corresponding preset gradient style for the abbreviation '" +
sPresetGradientStyleKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_PresetGradientType;
}
ChartReturns_PresetTextureType
public Office.MsoPresetTexture ChartReturns_PresetTextureType(
string sPresetTextureTypeKey)
{
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
Office.MsoPresetTexture objtemp = 0;
switch (sPresetTextureTypeKey)
{
case "BRM":
objtemp = Office.MsoPresetTexture.msoTextureBrownMarble;
break;
case "COR":
objtemp = Office.MsoPresetTexture.msoTextureCork;
break;
case "GRN":
objtemp = Office.MsoPresetTexture.msoTextureGranite;
break;
case "GRM":
objtemp = Office.MsoPresetTexture.msoTextureGreenMarble;
break;
case "MDW":
objtemp = Office.MsoPresetTexture.msoTextureMediumWood;
break;
case "OAK":
objtemp = Office.MsoPresetTexture.msoTextureOak;
break;
case "SND":
objtemp = Office.MsoPresetTexture.msoTextureSand;
break;
case "WLN":
objtemp = Office.MsoPresetTexture.msoTextureWalnut;
break;
case "WTM":
objtemp = Office.MsoPresetTexture.msoTextureWhiteMarble;
break;
case "WMT":
objtemp = Office.MsoPresetTexture.msoTextureWovenMat;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Marker Style abbreviation : " + sPresetTextureTypeKey,
"ChartReturns_PresetTextureType"
);
break;
}
ChartReturns_PresetTextureType = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_PresetTextureType",
msMODULENAME,
"return the corresponding preset texture type for the abbreviation '" +
sPresetTextureTypeKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_PresetTextureType;
}
ChartReturns_TickLabelOrientation
public Excel.XlTickLabelOrientation ChartReturns_TickLabelOrientation(
string sTickLabelOrientationKey)
{
Excel.XlTickLabelOrientation objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sTickLabelOrientationKey)
{
case "AU":
objtemp = Excel.XlTickLabelOrientation.xlTickLabelOrientationAutomatic;
break;
case "DW":
objtemp = Excel.XlTickLabelOrientation.xlTickLabelOrientationDownward;
break;
case "HR":
objtemp = Excel.XlTickLabelOrientation.xlTickLabelOrientationHorizontal;
break;
case "AP":
objtemp = Excel.XlTickLabelOrientation.xlTickLabelOrientationUpward;
break;
case "VR":
objtemp = Excel.XlTickLabelOrientation.xlTickLabelOrientationVertical;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Tick Label Orientation abbreviation : " + sTickLabelOrientationKey,
"ChartReturns_TickLabelOrientation"
);
break;
}
ChartReturns_TickLabelOrientation = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_TickLabelOrientation",
msMODULENAME,
"return the corresponding tick label orientation for the abbreviation '" +
sTickLabelOrientationKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_TickLabelOrientation;
}
ChartReturns_TickLabelPosition
public Excel.XlTickLabelPosition ChartReturns_TickLabelPosition(
string sTickLabelPositionKey)
{
Excel.XlTickLabelPosition objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sTickLabelPositionKey)
{
case "NO":
objtemp = Excel.XlTickLabelPosition.xlTickLabelPositionNone;
break;
case "LW":
objtemp = Excel.XlTickLabelPosition.xlTickLabelPositionLow;
break;
case "HI":
objtemp = Excel.XlTickLabelPosition.xlTickLabelPositionHigh;
break;
case "NA":
objtemp = Excel.XlTickLabelPosition.xlTickLabelPositionNextToAxis;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Tick Label Position abbreviation : " + sTickLabelPositionKey,
"ChartReturns_TickLabelPosition"
);
break;
}
ChartReturns_TickLabelPosition = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_TickLabelPosition",
msMODULENAME,
"return the corresponding tick label position for the abbreviation '" +
sTickLabelPositionKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_TickLabelPosition;
}
ChartReturns_TickMarkPosition
public Excel.XlTickMark ChartReturns_TickMarkPosition(
string sTickMarkPositionKey)
{
Excel.XlTickMark objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sTickMarkPositionKey)
{
case "NO":
objtemp = Excel.XlTickMark.xlTickMarkNone;
break;
case "OU":
objtemp = Excel.XlTickMark.xlTickMarkOutside;
break;
case "IN":
objtemp = Excel.XlTickMark.xlTickMarkInside;
break;
case "CR":
objtemp = Excel.XlTickMark.xlTickMarkCross;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Tick Mark Position abbreviation : " + sTickMarkPositionKey,
"ChartReturns_TickMarkPosition"
);
break;
}
ChartReturns_TickMarkPosition = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_TickMarkPosition",
msMODULENAME,
"return the corresponding tick mark position for the abbreviation '" +
sTickMarkPositionKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_TickMarkPosition;
}
ChartReturns_TimeSeriesUnit
public Excel.XlTimeUnit ChartReturns_TimeSeriesUnit(
string sTimeSeriesUnitKey)
{
Excel.XlTimeUnit objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sTimeSeriesUnitKey)
{
case "D":
objtemp = Excel.XlTimeUnit.xlDays;
break;
case "M":
objtemp = Excel.XlTimeUnit.xlMonths;
break;
case "Y":
objtemp = Excel.XlTimeUnit.xlYears;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Time Series Base abbreviation : " + sTimeSeriesUnitKey,
"ChartReturns_TimeSeriesBase"
);
break;
}
ChartReturns_TimeSeriesUnit = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_TimeSeriesUnit",
msMODULENAME,
"return the corresponding time series unit for the abbreviation '" +
sTimeSeriesUnitKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_TimeSeriesUnit;
}
ChartReturns_UnderlineStyle
public Excel.XlUnderlineStyle ChartReturns_UnderlineStyle(
string sUnderlineStyleKey)
{
Excel.XlUnderlineStyle objtemp = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sUnderlineStyleKey)
{
case "NO":
objtemp = Excel.XlUnderlineStyle.xlUnderlineStyleNone;
break;
case "SN":
objtemp = Excel.XlUnderlineStyle.xlUnderlineStyleSingle;
break;
case "DB":
objtemp = Excel.XlUnderlineStyle.xlUnderlineStyleDouble;
break;
default:
System.Windows.Forms.MessageBox.Show(
"Incorrect Underline abbreviation : " + sUnderlineStyleKey,
"ChartReturns_BackgroundType"
);
break;
}
ChartReturns_UnderlineStyle = objtemp;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objtemp = 0;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartReturns_UnderlineType",
msMODULENAME,
"return the corresponding underline type for the abbreviation '" +
sUnderlineStyleKey + "'.",
gobjCOMException,
gobjException
);
}
}
return ChartReturns_UnderlineStyle;
}
ChartSeries_AxisChange
public void ChartSeries_AxisChange(
Excel.Series objSeries,
string sAxisGroup)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (sAxisGroup == "P")
objSeries.AxisGroup = Excel.XlAxisGroup.xlPrimary;
if (sAxisGroup == "S")
objSeries.AxisGroup = Excel.XlAxisGroup.xlSecondary;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartSeries_AxisChange",
msMODULENAME,
"change the axis that series " + objSeries.Name + " is using.",
gobjCOMException,
gobjException
);
}
}
}
ChartSeries_AxisUsed
public string ChartSeries_AxisUsed(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return null;
}
if (objSeries.AxisGroup == Excel.XlAxisGroup.xlPrimary)
return "P";
if (objSeries.AxisGroup == Excel.XlAxisGroup.xlSecondary)
return "S";
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartSeries_AxisUsed",
msMODULENAME,
"return the axis that series " + objSeries.Name + " is using.",
gobjCOMException,
gobjException
);
}
}
return null;
}
ChartSeries_Format
public void ChartSeries_Format(
Excel.Chart objChart,
string sFormatType,
Excel.Series objSeries,
int iSeriesNo)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
int iser = iSeriesNo;
string chartTypeKey =
objSeries.ChartType.ToString() +
new string(' ', 26 - objSeries.ChartType.ToString().Length);
switch (chartTypeKey)
{
case "xlColumnClustered ":
ChartSeries_FormatColumn(objChart, objSeries, iser);
break;
case "xlColumnStacked ":
ChartSeries_FormatStacked(objChart, objSeries, iser);
break;
case "xlColumnStacked100 ":
ChartSeries_FormatStacked100(objChart, objSeries, iser);
break;
case "xl3DColumnClustered ":
ChartSeries_FormatColumn(objChart, objSeries, iser);
break;
case "xl3DColumnStacked ":
ChartSeries_FormatStacked(objChart, objSeries, iser);
break;
case "xl3DColumnStacked100 ":
ChartSeries_FormatStacked100(objChart, objSeries, iser);
break;
case "xl3DColumn ":
ChartSeries_FormatColumn(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlBarClustered ":
ChartSeries_FormatBar(objChart, objSeries, iser);
break;
case "xlBarStacked ":
ChartSeries_FormatStacked(objChart, objSeries, iser);
break;
case "xlBarStacked100 ":
ChartSeries_FormatStacked100(objChart, objSeries, iser);
break;
case "xl3DBarClustered ":
ChartSeries_FormatBar(objChart, objSeries, iser);
break;
case "xl3DBarStacked ":
ChartSeries_FormatStacked(objChart, objSeries, iser);
break;
case "xl3DBarStacked100 ":
ChartSeries_FormatStacked100(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlLine ":
ChartSeries_FormatLine(objChart, objSeries, iser);
break;
case "xlLineStacked ":
ChartSeries_FormatLine(objChart, objSeries, iser);
break;
case "xlLineStacked100 ":
ChartSeries_FormatStacked100(objChart, objSeries, iser);
break;
case "xlLineMarkers ":
ChartSeries_FormatLine(objChart, objSeries, iser);
break;
case "xlLineMarkersStacked ":
ChartSeries_FormatLine(objChart, objSeries, iser);
break;
case "xlLineMarkersStacked100 ":
ChartSeries_FormatStacked100(objChart, objSeries, iser);
break;
case "xl3DLine ":
ChartSeries_FormatLine(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlPie ":
case "xlPieExploded ":
case "xlPieOfPie ":
case "xl3DPie ":
case "xl3DPieExploded ":
ChartSeries_FormatPie(objChart, objSeries, iser);
break;
case "xlBarOfPie ":
ChartSeries_FormatBar(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlXYScatter ":
case "xlXYScatterLines ":
case "xlXYScatterLinesNoMarkers ":
case "xlXYScatterSmooth ":
case "xlXYScatterSmoothNoMarkers":
ChartSeries_FormatScatter(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlArea ":
case "xlAreaStacked ":
case "xl3DArea ":
case "xl3DAreaStacked ":
ChartSeries_FormatArea(objChart, objSeries, iser);
break;
case "xlAreaStacked100 ":
case "xl3DAreaStacked100 ":
ChartSeries_FormatStacked100(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlDoughnut ":
case "xlDoughnutExploded ":
ChartSeries_FormatDoughnut(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlRadar ":
case "xlRadarMarkers ":
ChartSeries_FormatRadar(objChart, objSeries, iser);
break;
case "xlRadarFilled ":
// Not recognised (-4111)
break;
// ---------------------------------------------------------
case "xlSurface ":
case "xlSurfaceWireframe ":
case "xlSurfaceTopView ":
case "xlSurfaceTopViewWireframe ":
ChartSeries_FormatScatter(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlBubble ":
case "xlBubble3DEffect ":
ChartSeries_FormatBubble(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlStockHLC ":
case "xlStockVHLC ":
case "xlStockOHLC ":
case "xlStockVOHLC ":
ChartSeries_FormatStock(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlCylinderCol ":
case "xlCylinderBarClustered ":
case "xlCylinderBarStacked ":
case "xlCylinderBarStacked100 ":
case "xlCylinderColClustered ":
case "xlCylinderColStacked ":
case "xlCylinderColStacked100 ":
ChartSeries_FormatColumn(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlConeBarClustered ":
case "xlConeBarStacked ":
case "xlConeBarStacked100 ":
case "xlConeCol ":
case "xlConeColClustered ":
case "xlConeColStacked ":
case "xlConeColStacked100 ":
ChartSeries_FormatColumn(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlPyramidBarClustered ":
case "xlPyramidBarStacked ":
case "xlPyramidBarStacked100 ":
case "xlPyramidCol ":
case "xlPyramidColClustered ":
case "xlPyramidColStacked ":
case "xlPyramidColStacked100 ":
ChartSeries_FormatColumn(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "-4111 ":
// RadarFilled or stock-series type mismatch
break;
default:
System.Windows.Forms.MessageBox.Show(
" chart type \"" + objSeries.ChartType.ToString() + "\" is not valid!");
break;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartType_SeriesFormat",
msMODULENAME,
"format series " + iSeriesNo +
" which has chart type ??? on the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_Format_LineOrArea
public void ChartSeries_Format_LineOrArea(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
int iser;
string chartTypeKey;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
iser = iSeriesNo;
chartTypeKey =
objSeries.ChartType.ToString() +
new string(' ', 26 - objSeries.ChartType.ToString().Length);
switch (chartTypeKey)
{
case "xlColumnClustered ":
case "xlColumnStacked ":
case "xlColumnStacked100 ":
case "xl3DColumnClustered ":
case "xl3DColumnStacked ":
case "xl3DColumnStacked100 ":
case "xl3DColumn ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlBarClustered ":
case "xlBarStacked ":
case "xlBarStacked100 ":
case "xl3DBarClustered ":
case "xl3DBarStacked ":
case "xl3DBarStacked100 ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlLine ":
case "xlLineStacked ":
case "xlLineStacked100 ":
case "xlLineMarkers ":
case "xlLineMarkersStacked ":
case "xlLineMarkersStacked100 ":
case "xl3DLine ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlPie ":
case "xlPieExploded ":
case "xlPieOfPie ":
case "xl3DPie ":
case "xl3DPieExploded ":
case "xlBarOfPie ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlXYScatter ":
case "xlXYScatterLines ":
case "xlXYScatterLinesNoMarkers ":
case "xlXYScatterSmooth ":
case "xlXYScatterSmoothNoMarkers":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlArea ":
case "xlAreaStacked ":
case "xlAreaStacked100 ":
case "xl3DArea ":
case "xl3DAreaStacked ":
case "xl3DAreaStacked100 ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlDoughnut ":
case "xlDoughnutExploded ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlRadar ":
case "xlRadarMarkers ":
case "xlRadarFilled ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlSurface ":
case "xlSurfaceWireframe ":
case "xlSurfaceTopView ":
case "xlSurfaceTopViewWireframe ":
// ?????
break;
// ---------------------------------------------------------
case "xlBubble ":
case "xlBubble3DEffect ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlStockHLC ":
case "xlStockVHLC ":
case "xlStockOHLC ":
case "xlStockVOHLC ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlCylinderCol ":
case "xlCylinderBarClustered ":
case "xlCylinderBarStacked ":
case "xlCylinderBarStacked100 ":
case "xlCylinderColClustered ":
case "xlCylinderColStacked ":
case "xlCylinderColStacked100 ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlConeBarClustered ":
case "xlConeBarStacked ":
case "xlConeBarStacked100 ":
case "xlConeCol ":
case "xlConeColClustered ":
case "xlConeColStacked ":
case "xlConeColStacked100 ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "xlPyramidBarClustered ":
case "xlPyramidBarStacked ":
case "xlPyramidBarStacked100 ":
case "xlPyramidCol ":
case "xlPyramidColClustered ":
case "xlPyramidColStacked ":
case "xlPyramidColStacked100 ":
ChartFormat_SeriesArea(objChart, objSeries, iser);
break;
// ---------------------------------------------------------
case "-4111 ":
// Do nothing, matches VB behaviour
break;
default:
System.Windows.Forms.MessageBox.Show(
" chart type '" + objSeries.ChartType.ToString() + "' is not valid !");
break;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartType_SeriesFormatLineOrArea",
msMODULENAME,
"format series " + iSeriesNo +
" which has chart type " +
(objSeries != null ? objSeries.ChartType.ToString() : "???") +
" on the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_Format3D
public void ChartSeries_Format3D(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
// With objChart
// .Elevation = 15;
// .Rotation = 20;
// End With
// If it's a 3D bar chart then
// can specify the bar shape
// objChart.BarShape = Return_3DBarShape("");
// call format_flooroptions
// call format_wallsoptions
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_Format3D",
msMODULENAME,
"apply the customised '3D' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatArea
public void ChartSeries_FormatArea(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objSeries.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowNone);
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatArea",
msMODULENAME,
"apply the customised 'Area' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatBar
public void ChartSeries_FormatBar(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo,
int iGapWidth = 100,
bool bHasSeriesLine = false,
bool bShadow = false,
int iOverlapWidth = 0,
bool bVaryByCategories = false,
int iChartDepth = 150,
int iGapDepth = 100)
{
Excel.ChartGroup objChartGroup = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objSeries.Shadow = bShadow;
objSeries.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowNone);
objChartGroup = (Excel.ChartGroup)objChart.ChartGroups(1);
objChartGroup.Overlap = iOverlapWidth;
objChartGroup.GapWidth = iGapWidth;
objChartGroup.HasSeriesLines = bHasSeriesLine;
objChartGroup.VaryByCategories = bVaryByCategories;
if (ChartType_SeriesTypeIsIt3D(objSeries) == true)
ChartSeries_Format3D(objChart, objSeries, iSeriesNo);
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
objChartGroup = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatBar",
msMODULENAME,
"apply the customised 'Bar' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatBubble
public void ChartSeries_FormatBubble(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo,
int iBorderColour = 0,
int iBorderWeight = 1,
string sBorderLineStyle = "NO",
int iInteriorColourIdx = 0,
bool bHas3DEffect = true)
{
Excel.ChartGroup objChartGroup = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
if (objChart.HasLegend == true)
objChart.Legend.Delete();
objSeries.Border.Color = iBorderColour;
objSeries.Border.Weight = ChartReturns_BorderWeight(iBorderWeight);
objSeries.Border.LineStyle = ChartReturns_LineStyle(sBorderLineStyle);
objChartGroup = (Excel.ChartGroup)objChart.ChartGroups(1);
objChartGroup.ShowNegativeBubbles = false;
objChartGroup.SizeRepresents = Excel.XlSizeRepresents.xlSizeIsArea;
objChartGroup.BubbleScale = 100;
objSeries.Has3DEffect = bHas3DEffect; // greyed out in Excel UI
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
objChartGroup = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatBubble",
msMODULENAME,
"apply the customised 'Bubble' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatClustered
public void ChartSeries_FormatClustered(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
// No formatting logic in VB version
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatClustered",
msMODULENAME,
"apply the customised 'Clustered' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatColumn
public void ChartSeries_FormatColumn(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo,
int iBorderColourIdx = giDEF_PALETTEAXESCOLOUR,
int iBorderWeight = 1,
string sBorderLineStyle = "NO",
int iGapWidth = 100,
bool bHasSeriesLine = false,
bool bShadow = false,
int iOverlapWidth = 0,
bool bVaryByCategories = false,
int iChartDepth = 150,
int iGapDepth = 100)
{
Excel.ChartGroup objChartGroup = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objSeries.Border.ColorIndex = iBorderColourIdx;
objSeries.Border.Weight = ChartReturns_BorderWeight(iBorderWeight);
objSeries.Border.LineStyle = ChartReturns_LineStyle(sBorderLineStyle);
objSeries.Shadow = bShadow;
objSeries.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowNone);
objChartGroup = (Excel.ChartGroup)objChart.ChartGroups(1);
objChartGroup.Overlap = iOverlapWidth;
objChartGroup.GapWidth = iGapWidth;
objChartGroup.HasSeriesLines = bHasSeriesLine;
objChartGroup.VaryByCategories = bVaryByCategories;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
objChartGroup = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatColumn",
msMODULENAME,
"apply the customised 'Column' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatCone
public void ChartSeries_FormatCone(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
// No formatting logic in VB version
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatCone",
msMODULENAME,
"apply the customised 'Cone' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatCylinder
public void ChartSeries_FormatCylinder(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
// No formatting logic in VB version
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatCylinder",
msMODULENAME,
"apply the customised 'Cylinder' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatDoughnut
public void ChartSeries_FormatDoughnut(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
Excel.ChartArea objChartArea = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
float sngchartwidth;
float sngchartheight;
string ssmallestside = "";
int ismallestlength = 0;
int idivisionlength = 0;
objChartArea = objChart.ChartArea;
// ----------------- sizing the doughnut chart and centering
if (objChartArea.Width <= objChartArea.Height)
{
ismallestlength = (int)objChartArea.Width;
ssmallestside = "W";
}
if (objChartArea.Height < objChartArea.Width)
{
ismallestlength = (int)objChartArea.Height;
ssmallestside = "H";
}
idivisionlength = (int)(ismallestlength / 6.0);
objChart.PlotArea.Width = idivisionlength * 4;
if (ssmallestside == "H")
{
objChart.PlotArea.Top = idivisionlength;
objChart.PlotArea.Left = (objChart.ChartArea.Width - objChart.ChartArea.Height) / 2;
objChart.PlotArea.Left = objChart.PlotArea.Left + idivisionlength;
}
if (ssmallestside == "W")
{
objChart.PlotArea.Left = idivisionlength;
objChart.PlotArea.Top = (objChart.ChartArea.Height - objChart.ChartArea.Width) / 2;
objChart.PlotArea.Top = objChart.PlotArea.Top + idivisionlength;
}
// ----------------------------
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
objChartArea = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatDoughnut",
msMODULENAME,
"apply the customised 'Doughnut' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatLine
public void ChartSeries_FormatLine(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo,
int iBorderColour = 0,
int iBorderWeight = 3,
string sBorderLineStyle = "CT",
bool bSmooth = false,
int iMarkerForeColour = 0,
int iMarkerBackColour = 0,
string sMarkerStyleKey = "NO",
int iMarkerSize = 3,
bool bMarkerShadow = false,
bool bDropLines = false,
bool bHiLoLines = false,
bool bUpDownBars = false,
int iGapWidth = 0,
bool bVaryByCategories = false)
{
Excel.ChartGroup objChartGroup1 = null;
Excel.ChartGroup objChartGroup2 = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
// -------------------------
// SERIES BORDER & LINE STYLE
// -------------------------
if (iBorderColour == 0)
{
objSeries.Border.ColorIndex = Colour_LineReturn(iSeriesNo);
}
else
{
objSeries.Border.Color = iBorderColour;
}
objSeries.Border.LineStyle = ChartReturns_LineStyle(sBorderLineStyle);
objSeries.Border.Weight = ChartReturns_BorderWeight(iBorderWeight);
objSeries.Smooth = bSmooth;
objSeries.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowNone);
// -------------------------
// MARKER SETTINGS
// -------------------------
if (sMarkerStyleKey != "NO")
{
objSeries.MarkerForegroundColorIndex =
(Excel.XlColorIndex)iMarkerForeColour;
objSeries.MarkerBackgroundColorIndex =
(Excel.XlColorIndex)iMarkerBackColour;
objSeries.MarkerStyle = ChartReturns_MarkerStyle(sMarkerStyleKey);
objSeries.MarkerSize = iMarkerSize;
objSeries.Shadow = bMarkerShadow;
}
// -------------------------
// AXIS-DEPENDENT CHART GROUPS
// -------------------------
string axisUsed = ChartSeries_AxisUsed(objSeries);
if (axisUsed == "P")
{
objChartGroup1 = (Excel.ChartGroup)objChart.ChartGroups(1);
objChartGroup1.HasDropLines = bDropLines;
objChartGroup1.HasHiLoLines = bHiLoLines;
objChartGroup1.HasUpDownBars = bUpDownBars;
objChartGroup1.VaryByCategories = bVaryByCategories;
}
if (axisUsed == "S")
{
objChartGroup2 = (Excel.ChartGroup)objChart.ChartGroups(2);
objChartGroup2.HasDropLines = bDropLines;
objChartGroup2.HasHiLoLines = bHiLoLines;
objChartGroup2.HasUpDownBars = bUpDownBars;
objChartGroup2.VaryByCategories = bVaryByCategories;
}
// -------------------------
// 3D FORMATTING
// -------------------------
if (ChartType_SeriesTypeIsIt3D(objSeries) == true)
{
ChartSeries_Format3D(objChart, objSeries, iSeriesNo);
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
objChartGroup1 = null;
objChartGroup2 = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatLine",
msMODULENAME,
"apply the customised 'Line' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatPie
public void ChartSeries_FormatPie(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo,
int iBorderColour = 0,
int iBorderWeight = 1,
string sBorderLineStyle = "NO",
int iFirstAngleSlice = 0,
int iExplosion = 0,
bool bVaryByCategories = true)
{
Excel.ChartGroup objChartGroup = null;
Excel.ChartArea objChartArea = null;
Excel.Points objPointsCol = null;
Excel.Point objPoint = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
float sngchartwidth;
float sngchartheight;
int icount;
int ipointcount;
string ssmallestside = "";
int ismallestlength = 0;
int idivisionlength = 0;
objChartArea = objChart.ChartArea;
// -------------------------
// SERIES + GROUP FORMATTING
// -------------------------
objChartGroup = (Excel.ChartGroup)objChart.ChartGroups(1);
objChartGroup.VaryByCategories = bVaryByCategories;
objChartGroup.FirstSliceAngle = iFirstAngleSlice;
objSeries.Explosion = iExplosion;
objSeries.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowPercent);
objSeries.HasLeaderLines = false;
objPointsCol = (Excel.Points)objSeries.Points;
for (ipointcount = 1; ipointcount <= objPointsCol.Count; ipointcount++)
{
objPoint = (Excel.Point)objSeries.Points(ipointcount);
objPoint.Border.Color = iBorderColour;
objPoint.Border.Weight = ChartReturns_BorderWeight(iBorderWeight);
objPoint.Border.LineStyle = ChartReturns_LineStyle(sBorderLineStyle);
objPoint.Interior.Pattern = Excel.XlPattern.xlPatternSolid;
objPoint.Interior.ColorIndex = Colour_AreaReturn(ipointcount);
}
// -------------------------
// PIE SIZING + CENTERING
// -------------------------
if (objChartArea.Width <= objChartArea.Height)
{
ismallestlength = (int)objChartArea.Width;
ssmallestside = "W";
}
if (objChartArea.Height < objChartArea.Width)
{
ismallestlength = (int)objChartArea.Height;
ssmallestside = "H";
}
if (!objChart.HasLegend)
{
idivisionlength = (int)(ismallestlength / 6.0);
objChart.PlotArea.Width = idivisionlength * 4;
if (ssmallestside == "H")
{
objChart.PlotArea.Top = idivisionlength;
objChart.PlotArea.Left = (objChart.ChartArea.Width - objChart.ChartArea.Height) / 2;
objChart.PlotArea.Left += idivisionlength;
}
if (ssmallestside == "W")
{
objChart.PlotArea.Left = idivisionlength;
objChart.PlotArea.Top = (objChart.ChartArea.Height - objChart.ChartArea.Width) / 2;
objChart.PlotArea.Top += idivisionlength;
}
}
else
{
if (App_RegTypesPieAutomaticLegendPositionRead() == true)
{
if (ssmallestside == "H")
{
// legend on right
ChartFormat_LegendSizePosition(objChart, "RI");
}
if (ssmallestside == "W")
{
// legend below
ChartFormat_LegendSizePosition(objChart, "BT");
}
}
idivisionlength = (int)(ismallestlength / 6.0);
objChart.PlotArea.Width = idivisionlength * 4;
if (ssmallestside == "H")
{
objChart.PlotArea.Top = idivisionlength;
objChart.PlotArea.Left = (objChart.ChartArea.Width - objChart.ChartArea.Height) / 2;
objChart.PlotArea.Left += idivisionlength;
// shift left because legend is on the right
objChart.PlotArea.Left -= (objChart.Legend.Width / 2);
}
if (ssmallestside == "W")
{
objChart.PlotArea.Left = idivisionlength;
objChart.PlotArea.Top = (objChart.ChartArea.Height - objChart.ChartArea.Width) / 2;
objChart.PlotArea.Top += idivisionlength;
// shift up because legend is below
objChart.PlotArea.Top -= (objChart.Legend.Height / 2);
}
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
objChartGroup = null;
objChartArea = null;
objPointsCol = null;
objPoint = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatPie",
msMODULENAME,
"apply the customised 'Pie' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatPyramid
public void ChartSeries_FormatPyramid(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
// No formatting logic in VB version
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatPyramid",
msMODULENAME,
"apply the customised 'Pyramid' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatRadar
public void ChartSeries_FormatRadar(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
Excel.ChartArea objChartArea = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
float sngchartwidth;
float sngchartheight;
string ssmallestside = "";
int ismallestlength = 0;
int idivisionlength = 0;
objChartArea = objChart.ChartArea;
// ----------------- sizing the radar chart and centering
if (objChartArea.Width <= objChartArea.Height)
{
ismallestlength = (int)objChartArea.Width;
ssmallestside = "W";
}
if (objChartArea.Height < objChartArea.Width)
{
ismallestlength = (int)objChartArea.Height;
ssmallestside = "H";
}
idivisionlength = (int)(ismallestlength / 6.0);
objChart.PlotArea.Width = idivisionlength * 4;
if (ssmallestside == "H")
{
objChart.PlotArea.Top = idivisionlength;
objChart.PlotArea.Left = (objChart.ChartArea.Width - objChart.ChartArea.Height) / 2;
objChart.PlotArea.Left += idivisionlength;
}
if (ssmallestside == "W")
{
objChart.PlotArea.Left = idivisionlength;
objChart.PlotArea.Top = (objChart.ChartArea.Height - objChart.ChartArea.Width) / 2;
objChart.PlotArea.Top += idivisionlength;
}
// ----------------------------
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatRadar",
msMODULENAME,
"apply the customised 'Radar' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatScatter
public void ChartSeries_FormatScatter(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
// remove the line
// If sChartType = "S" Then
// If iInteriorColourIdx = 0 Then .Interior.ColorIndex = 16 + iSeriesNo
// If iInteriorColourIdx > 0 Then .Interior.ColorIndex = 16 + iInteriorColourIdx
// .MarkerStyle
// .MarkerBackgroundColorIndex
// .MarkerForegroundColorIndex
// .MarkerSize
// .Shadow
// End If
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatScatter",
msMODULENAME,
"apply the customised 'Scatter' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatStacked
public void ChartSeries_FormatStacked(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo,
int iGapWidth = 100,
bool bHasSeriesLine = false,
bool bShadow = false,
int iOverlapWidth = 100,
bool bVaryByCategories = false,
int iChartDepth = 150,
int iGapDepth = 100)
{
Excel.ChartGroup objChartGroup = null;
Excel.Axis objAxis = null;
Excel.TickLabels objTickLabels = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objSeries.Shadow = bShadow;
objSeries.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowNone);
objChartGroup = (Excel.ChartGroup)objChart.ChartGroups(1);
objChartGroup.Overlap = iOverlapWidth;
objChartGroup.GapWidth = iGapWidth;
objChartGroup.HasSeriesLines = bHasSeriesLine;
objChartGroup.VaryByCategories = bVaryByCategories;
objAxis = (Excel.Axis)objChart.Axes(
Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlPrimary);
if (ChartType_SeriesTypeIsItStacked100(objSeries) == true)
{
objTickLabels = (Excel.TickLabels)objAxis.TickLabels;
objTickLabels.NumberFormat = "0%";
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
objChartGroup = null;
objAxis = null;
objTickLabels = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatStacked",
msMODULENAME,
"apply the customised 'Stacked' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatStacked100
public void ChartSeries_FormatStacked100(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo,
int iGapWidth = 100,
bool bHasSeriesLine = false,
bool bShadow = false,
int iOverlapWidth = 100,
bool bVaryByCategories = false,
int iChartDepth = 150,
int iGapDepth = 100)
{
Excel.ChartGroup objChartGroup = null;
Excel.Axis objAxis = null;
Excel.TickLabels objTickLabels = null;
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
bool bvertically = ChartType_SeriesTypeIsItStacked100Vertical(objSeries);
bool bhorizontally = ChartType_SeriesTypeIsItStacked100Horizontal(objSeries);
objSeries.Shadow = bShadow;
objSeries.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowNone);
objChartGroup = (Excel.ChartGroup)objChart.ChartGroups(1);
objChartGroup.Overlap = iOverlapWidth;
objChartGroup.GapWidth = iGapWidth;
objChartGroup.HasSeriesLines = bHasSeriesLine;
objChartGroup.VaryByCategories = bVaryByCategories;
objAxis = (Excel.Axis)objChart.Axes(
Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlPrimary);
objTickLabels = (Excel.TickLabels)objAxis.TickLabels;
objTickLabels.NumberFormat = "0%";
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
objChartGroup = null;
objAxis = null;
objTickLabels = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatStacked100",
msMODULENAME,
"apply the customised 'Stacked 100' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatStock
public void ChartSeries_FormatStock(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
// No formatting logic in VB version
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatStock",
msMODULENAME,
"apply the customised 'Stock' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormatSurface
public void ChartSeries_FormatSurface(
Excel.Chart objChart,
Excel.Series objSeries,
int iSeriesNo)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
// No formatting logic in VB version
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartSeries_FormatSurface",
msMODULENAME,
"apply the customised 'Surface' formatting to the active chart.",
mobjCOMException,
mobjException
);
}
}
}
ChartSeries_FormulaXValuesGet
public string ChartSeries_FormulaXValuesGet(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
string sFormula;
int icharpos;
sFormula = objSeries.Formula;
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) - Microsoft.VisualBasic.Strings.Len("=SERIES(")
);
if (Microsoft.VisualBasic.Strings.Left(sFormula, 1) != "'")
{
icharpos = Microsoft.VisualBasic.Strings.InStr(sFormula, ",");
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) - icharpos
);
}
else
{
icharpos = clsStr.FindPositionOfOddSeq(sFormula, "!", "'", 3);
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) - icharpos
);
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) -
Microsoft.VisualBasic.Strings.InStr(sFormula, ",")
);
}
if (Microsoft.VisualBasic.Strings.Left(sFormula, 1) != "'")
{
icharpos = Microsoft.VisualBasic.Strings.InStr(sFormula, ",");
}
if (Microsoft.VisualBasic.Strings.Left(sFormula, 1) == "'")
{
icharpos = clsStr.FindPositionOfOddSeq(sFormula, "!", "'", 3);
}
return Microsoft.VisualBasic.Strings.Left(
sFormula,
Microsoft.VisualBasic.Strings.InStr(icharpos, sFormula, ",") - 1
);
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartSeries_FormulaLabelsGet",
msMODULENAME,
"return the series 'LABELS' component for series " +
objSeries?.Name + " for the active chart",
gobjCOMException,
gobjException
);
}
}
return null;
}
ChartSeries_FormulaYValuesGet
public string ChartSeries_FormulaValuesGet(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return null;
}
string sFormula;
int icharpos;
sFormula = objSeries.Formula;
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) -
Microsoft.VisualBasic.Strings.Len("=SERIES(")
);
if (Microsoft.VisualBasic.Strings.Left(sFormula, 1) != "'")
{
icharpos = Microsoft.VisualBasic.Strings.InStr(sFormula, ",");
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) - icharpos
);
}
else
{
icharpos = clsStr.FindPositionOfOddSeq(sFormula, "!", "'", 3);
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) - icharpos
);
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) -
Microsoft.VisualBasic.Strings.InStr(sFormula, ",")
);
}
if (Microsoft.VisualBasic.Strings.Left(sFormula, 1) != "'")
{
icharpos = Microsoft.VisualBasic.Strings.InStr(sFormula, ",");
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) - icharpos
);
}
else
{
icharpos = clsStr.FindPositionOfOddSeq(sFormula, "!", "'", 3);
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) - icharpos
);
sFormula = Microsoft.VisualBasic.Strings.Right(
sFormula,
Microsoft.VisualBasic.Strings.Len(sFormula) -
Microsoft.VisualBasic.Strings.InStr(sFormula, ",")
);
}
return Microsoft.VisualBasic.Strings.Left(
sFormula,
Microsoft.VisualBasic.Strings.InStr(1, sFormula, ",") - 1
);
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartSeries_FormulaValuesGet",
msMODULENAME,
"return the series 'VALUES' component for series " +
objSeries?.Name + " for the active chart",
gobjCOMException,
gobjException
);
}
}
return null;
}
ChartSeries_Type_Change
public void ChartSeries_Type_Change(
Excel.Series objSeries,
Excel.XlChartType iChartType)
{
try
{
if (clsError.ErrorFlag() == true)
{
return;
}
objSeries.ChartType = (Excel.XlChartType)iChartType;
objSeries.Select();
}
catch (Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true | ((IsNothing(gobjCOMException) == false | IsNothing(gobjException) == false)))
clsError.Handle("Chart_SeriesTypeChange", msMODULENAME, "change the type of the active chart series.", gobjCOMException, gobjException);
}
}
ChartSeries_Type_Convert
public long ChartSeries_Type_Convert(
int iSeriesNo)
{
Excel.Chart objChart = null;
Excel.Series objSeries = null;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
int itype;
objChart = gApplication.ActiveChart;
objSeries = (Excel.Series)objChart.SeriesCollection(iSeriesNo);
switch (objSeries.ChartType.ToString() +
new string(' ', 26 - objSeries.ChartType.ToString().Length))
{
case "xlColumnClustered ": itype = xlColumnClustered; break;
case "xlColumnStacked ": itype = xlColumnStacked; break;
case "xlColumnStacked100 ": itype = xlColumnStacked100; break;
case "xl3DColumnClustered ": itype = xlColumnClustered; break;
case "xl3DColumnStacked ": itype = xlColumnStacked; break;
case "xl3DColumnStacked100 ": itype = xlColumnStacked100; break;
case "xl3DColumn ": itype = xlColumnClustered; break;
case "xlBarClustered ": itype = xlBarClustered; break;
case "xlBarStacked ": itype = xlBarStacked; break;
case "xlBarStacked100 ": itype = xlBarStacked100; break;
case "xl3DBarClustered ": itype = xlBarClustered; break;
case "xl3DBarStacked ": itype = xlBarStacked; break;
case "xl3DBarStacked100 ": itype = xlBarStacked100; break;
case "xlLine ": itype = xlLine; break;
case "xlLineStacked ": itype = xlLine; break;
case "xlLineStacked100 ": itype = xlLine; break;
case "xlLineMarkers ": itype = xlLine; break;
case "xlLineMarkersStacked ": itype = xlLine; break;
case "xlLineMarkersStacked100 ": itype = xlLine; break;
case "xl3DLine ": itype = xlLine; break;
case "xlPie ": itype = xlPie; break;
case "xlPieExploded ": itype = xlPie; break;
case "xlPieOfPie ": itype = xlPie; break;
case "xl3DPie ": itype = xlPie; break;
case "xl3DPieExploded ": itype = xlPie; break;
case "xlBarOfPie ": itype = xlPie; break;
case "xlXYScatter ": itype = xlXYScatter; break;
case "xlXYScatterLines ": itype = xlXYScatter; break;
case "xlXYScatterLinesNoMarkers ": itype = xlXYScatter; break;
case "xlXYScatterSmooth ": itype = xlXYScatter; break;
case "xlXYScatterSmoothNoMarkers": itype = xlXYScatter; break;
case "xlArea ": itype = xlArea; break;
case "xlAreaStacked ": itype = xlAreaStacked; break;
case "xlAreaStacked100 ": itype = xlAreaStacked100; break;
case "xl3DArea ": itype = xlArea; break;
case "xl3DAreaStacked ": itype = xlAreaStacked; break;
case "xl3DAreaStacked100 ": itype = xlAreaStacked100; break;
case "xlDoughnut ": itype = xlPie; break;
case "xlDoughnutExploded ": itype = xlPie; break;
case "xlRadar ": itype = xlRadar; break;
case "xlRadarMarkers ": itype = xlRadarMarkers; break;
case "xlRadarFilled ": itype = xlRadarFilled; break;
case "xlSurface ": itype = xlArea; break;
case "xlSurfaceWireframe ": itype = xlArea; break;
case "xlSurfaceTopView ": itype = xlArea; break;
case "xlSurfaceTopViewWireframe ": itype = xlArea; break;
case "xlBubble ": itype = xlColumnClustered; break;
case "xlBubble3DEffect ": itype = xlColumnClustered; break;
case "xlStockHLC ": itype = xlStockHLC; break;
case "xlStockVHLC ": itype = xlStockVHLC; break;
case "xlStockOHLC ": itype = xlStockOHLC; break;
case "xlStockVOHLC ": itype = xlStockVOHLC; break;
case "xlCylinderCol ": itype = xlColumnClustered; break;
case "xlCylinderBarClustered ": itype = xlBarClustered; break;
case "xlCylinderBarStacked ": itype = xlBarStacked; break;
case "xlCylinderBarStacked100 ": itype = xlBarStacked100; break;
case "xlCylinderColClustered ": itype = xlColumnClustered; break;
case "xlCylinderColStacked ": itype = xlColumnStacked; break;
case "xlCylinderColStacked100 ": itype = xlColumnStacked100; break;
case "xlConeBarClustered ": itype = xlBarClustered; break;
case "xlConeBarStacked ": itype = xlBarStacked; break;
case "xlConeBarStacked100 ": itype = xlBarStacked100; break;
case "xlConeCol ": itype = xlBarStacked; break;
case "xlConeColClustered ": itype = xlColumnClustered; break;
case "xlConeColStacked ": itype = xlColumnStacked; break;
case "xlConeColStacked100 ": itype = xlColumnStacked100; break;
case "xlPyramidBarClustered ": itype = xlBarClustered; break;
case "xlPyramidBarStacked ": itype = xlBarStacked; break;
case "xlPyramidBarStacked100 ": itype = xlBarStacked100; break;
case "xlPyramidCol ": itype = xlColumnClustered; break;
case "xlPyramidColClustered ": itype = xlColumnClustered; break;
case "xlPyramidColStacked ": itype = xlBarStacked; break;
case "xlPyramidColStacked100 ": itype = xlColumnStacked100; break;
default:
MsgBox(
"The chart type for the series " + iSeriesNo +
" on the active chart is " +
objSeries.ChartType.ToString() + "\r\n" +
"This chart type is not included on the list as yet!",
Title: "ChartType_SeriesTypeConvert"
);
break;
}
ChartType_SeriesTypeConvert = itype;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objChart = null;
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartType_SeriesTypeConvert",
msMODULENAME,
"convert the chart type for series " + iSeriesNo + "\r\n" +
"The current chart type is: " + objSeries?.ChartType.ToString() + ".",
mobjCOMException,
mobjException
);
}
}
return ChartType_SeriesTypeConvert;
}
ChartSeries_Type_IsIt3D
public bool ChartSeries_Type_IsIt3D(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return false;
}
switch (objSeries.ChartType)
{
case xl3DArea:
case xl3DAreaStacked:
case xl3DAreaStacked100:
case xl3DBarClustered:
case xl3DBarStacked:
case xl3DBarStacked100:
case xl3DColumn:
case xl3DColumnClustered:
case xl3DColumnStacked:
case xl3DColumnStacked100:
case xl3DLine:
case xl3DPie:
case xl3DPieExploded:
case xlCylinderCol:
case xlCylinderBarClustered:
case xlCylinderBarStacked:
case xlCylinderBarStacked100:
case xlCylinderColClustered:
case xlCylinderColStacked:
case xlCylinderColStacked100:
case xlConeBarClustered:
case xlConeBarStacked:
case xlConeBarStacked100:
case xlConeCol:
case xlConeColClustered:
case xlConeColStacked:
case xlConeColStacked100:
case xlPyramidBarClustered:
case xlPyramidBarStacked:
case xlPyramidBarStacked100:
case xlPyramidCol:
case xlPyramidColClustered:
case xlPyramidColStacked:
case xlPyramidColStacked100:
return true;
default:
return false;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartType_SeriesTypeIsIt3D",
msMODULENAME,
"determine if this series on the active chart is a '3D' chart type.",
mobjCOMException,
mobjException
);
}
}
return false;
}
ChartSeries_Type_IsItBubble
public bool ChartSeries_Type_IsItBubble(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return false;
}
switch (objSeries.ChartType)
{
case xlBubble:
case xlBubble3DEffect:
return true;
default:
return false;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartType_SeriesTypeIsItBubble",
msMODULENAME,
"determine if this series on the active chart is a 'Bubble' chart type.",
mobjCOMException,
mobjException
);
}
}
return false;
}
ChartSeries_Type_IsItDoughnut
public bool ChartSeries_Type_IsItDoughnut(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return false;
}
switch (objSeries.ChartType)
{
case xlDoughnut:
case xlDoughnutExploded:
return true;
default:
return false;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartType_SeriesTypeIsItDoughnut",
msMODULENAME,
"determine if this series on the active chart is a 'Doughnut' chart type.",
mobjCOMException,
mobjException
);
}
}
return false;
}
ChartSeries_Type_IsItPie
public bool ChartSeries_Type_IsItPie(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return false;
}
switch (objSeries.ChartType)
{
case xlPie:
case xlPieOfPie:
case xlBarOfPie:
case xlPieExploded:
case xl3DPie:
case xl3DPieExploded:
return true;
default:
return false;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"Chart_SeriesTypeIsItPie",
msMODULENAME,
"determine if this series on the active chart is a 'Pie' chart type.",
mobjCOMException,
mobjException
);
}
}
return false;
}
ChartSeries_Type_IsItStacked
public bool ChartSeries_Type_IsItStacked(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return false;
}
switch (objSeries.ChartType)
{
case xlAreaStacked:
case xl3DAreaStacked:
case xlBarStacked:
case xl3DBarStacked:
case xlColumnStacked:
case xl3DColumnStacked:
case xlConeBarStacked:
case xlConeColStacked:
case xlCylinderBarStacked:
case xlCylinderColStacked:
case xlLineMarkersStacked:
case xlLineStacked:
case xlPyramidBarStacked:
case xlPyramidColStacked:
return true;
default:
return false;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"Chart_SeriesTypeIsItStacked",
msMODULENAME,
"determine if this series on the active chart is a 'Stacked' chart type.",
mobjCOMException,
mobjException
);
}
}
return false;
}
ChartSeries_Type_IsItStacked100
public bool ChartSeries_Type_IsItStacked100(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return false;
}
if (ChartType_SeriesTypeIsItStacked100Horizontal(objSeries) ||
ChartType_SeriesTypeIsItStacked100Vertical(objSeries))
{
return true;
}
else
{
return false;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartType_SeriesTypeIsItStacked100",
msMODULENAME,
"determine if this series on the active chart is a 'Stacked 100' chart type.",
mobjCOMException,
mobjException
);
}
}
return false;
}
ChartSeries_Type_IsItStacked100Horizontal
public bool ChartSeries_Type_IsItStacked100Horizontal(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return false;
}
switch (objSeries.ChartType)
{
case xlBarStacked100:
case xl3DBarStacked100:
case xlConeBarStacked100:
case xlCylinderBarStacked100:
case xlPyramidBarStacked100:
return true;
default:
return false;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"Chart_SeriesTypeIsItStacked100Horizontal",
msMODULENAME,
"determine if this series on the active chart is a 'Horizontally Stacked' chart type.",
mobjCOMException,
mobjException
);
}
}
return false;
}
ChartSeries_Type_IsItStacked100Vertical
public bool ChartSeries_Type_IsItStacked100Vertical(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return false;
}
switch (objSeries.ChartType)
{
case xlAreaStacked100:
case xl3DAreaStacked100:
case xlColumnStacked100:
case xl3DColumnStacked100:
case xlConeColStacked100:
case xlCylinderColStacked100:
case xlLineMarkersStacked100:
case xlPyramidColStacked100:
return true;
default:
return false;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"Chart_SeriesTypeIsItStacked100Vertical",
msMODULENAME,
"determine if this series on the active chart is a 'Vertically Stacked' chart type",
mobjCOMException,
mobjException
);
}
}
return false;
}
ChartSeries_Type_IsItSurface
public bool ChartSeries_Type_IsItSurface(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return false;
}
switch (objSeries.ChartType)
{
case xlSurface:
case xlSurfaceWireframe:
case xlSurfaceTopView:
return true;
// xlsurfacetopviewwireframe:
// doesn't seem to recognise ??????
default:
return false;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
objSeries = null;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartType_SeriesTypeIsItSurface",
msMODULENAME,
"determine if this series on the active chart is a 'Surface' chart type",
mobjCOMException,
mobjException
);
}
}
return false;
}
ChartSeries_Type_NameToEnumeration
public Excel.XlChartType ChartSeries_Type_NameToEnumeration(
string sChartTypeName)
{
Excel.XlChartType lreturn = 0;
try
{
if (clsError.ErrorFlag() == true)
{
return 0;
}
switch (sChartTypeName + new string(' ', 30 - sChartTypeName.Length))
{
case "Area ": lreturn = xlArea; break;
case "Area - Stacked ": lreturn = xlAreaStacked; break;
case "Area - Stacked 100 ": lreturn = xlAreaStacked100; break;
case "Area - 3D ": lreturn = xl3DArea; break;
case "Area - 3D Stacked ": lreturn = xl3DAreaStacked; break;
case "Area - 3D Stacked 100 ": lreturn = xl3DAreaStacked100; break;
case "Bar - Clustered ": lreturn = xlBarClustered; break;
case "Bar - Clustered Cone ": lreturn = xlConeBarClustered; break;
case "Bar - Clustered Cylinder ": lreturn = xlCylinderBarClustered; break;
case "Bar - Clustered Pyramid ": lreturn = xlPyramidBarClustered; break;
case "Bar - Stacked ": lreturn = xlBarStacked; break;
case "Bar - Stacked Cone ": lreturn = xlConeBarStacked; break;
case "Bar - Stacked Cylinder ": lreturn = xlCylinderBarStacked; break;
case "Bar - Stacked Pyramid ": lreturn = xlPyramidBarStacked; break;
case "Bar - Stacked 100 ": lreturn = xlBarStacked100; break;
case "Bar - Stacked Cone 100 ": lreturn = xlConeBarStacked100; break;
case "Bar - Stacked Cylinder 100 ": lreturn = xlCylinderBarStacked100; break;
case "Bar - Stacked Pyramid 100 ": lreturn = xlPyramidBarStacked100; break;
case "Bar - 3D Clustered ": lreturn = xl3DBarClustered; break;
case "Bar - 3D Stacked ": lreturn = xl3DBarStacked; break;
case "Bar - 3D Stacked 100 ": lreturn = xl3DBarStacked100; break;
case "Bubble ": lreturn = xlBubble; break;
case "Bubble - 3D ": lreturn = xlBubble3DEffect; break;
case "Column - Clustered ": lreturn = xlColumnClustered; break;
case "Column - Clustered Cone ": lreturn = xlConeColClustered; break;
case "Column - Clustered Cylinder ": lreturn = xlCylinderColClustered; break;
case "Column - Clustered Pyramid ": lreturn = xlPyramidColClustered; break;
case "Column - Stacked ": lreturn = xlColumnStacked; break;
case "Column - Stacked Cone ": lreturn = xlConeColStacked; break;
case "Column - Stacked Cylinder ": lreturn = xlCylinderColStacked; break;
case "Column - Stacked Pyramid ": lreturn = xlPyramidColStacked; break;
case "Column - Stacked 100 ": lreturn = xlColumnStacked100; break;
case "Column - Stacked Cone 100 ": lreturn = xlConeColStacked100; break;
case "Column - Stacked Cylinder 100 ": lreturn = xlCylinderColStacked100; break;
case "Column - Stacked Pyramid 100 ": lreturn = xlPyramidColStacked100; break;
case "Column - 3D ": lreturn = xl3DColumn; break;
case "Column - 3D Clustered ": lreturn = xl3DColumnClustered; break;
case "Column - 3D Stacked ": lreturn = xl3DColumnStacked; break;
case "Column - 3D Stacked 100 ": lreturn = xl3DColumnStacked100; break;
case "Doughnut ": lreturn = xlDoughnut; break;
case "Doughnut - Exploded ": lreturn = xlDoughnutExploded; break;
case "Line ": lreturn = xlLine; break;
case "Line - Stacked ": lreturn = xlLineStacked; break;
case "Line - Stacked 100 ": lreturn = xlLineStacked100; break;
case "Line - Markers ": lreturn = xlLineMarkers; break;
case "Line - Markers Stacked ": lreturn = xlLineMarkersStacked; break;
case "Line - Markers Stacked 100 ": lreturn = xlLineMarkersStacked100; break;
case "Line - 3D ": lreturn = xl3DLine; break;
case "Pie ": lreturn = xlPie; break;
case "Pie - Exploded ": lreturn = xlPieExploded; break;
case "Pie - Of Pie ": lreturn = xlPieOfPie; break;
case "Pie - 3D ": lreturn = xl3DPie; break;
case "Pie - 3D Exploded ": lreturn = xl3DPieExploded; break;
case "Radar ": lreturn = xlRadar; break;
case "Radar - Markers ": lreturn = xlRadarMarkers; break;
case "Radar - Filled ": lreturn = xlRadarFilled; break;
case "Stock - High Low Close ": lreturn = xlStockHLC; break;
case "Stock - V High Low Close ": lreturn = xlStockVHLC; break;
case "Stock - O High Low Close ": lreturn = xlStockOHLC; break;
case "Stock - V O High Low Close ": lreturn = xlStockVOHLC; break;
case "Scatter XY ": lreturn = xlXYScatter; break;
case "Scatter XY - Lines ": lreturn = xlXYScatterLines; break;
case "Scatter XY - Lines No Markers ": lreturn = xlXYScatterLinesNoMarkers; break;
case "Scatter XY - Smooth ": lreturn = xlXYScatterSmooth; break;
case "Scatter XY - Smooth No Markers": lreturn = xlXYScatterSmoothNoMarkers; break;
case "Surface ": lreturn = xlSurface; break;
case "Surface - WireFrame ": lreturn = xlSurfaceWireframe; break;
case "Surface (TopView) ": lreturn = xlSurfaceTopView; break;
case "Surface - WireFrame (Top view)": lreturn = xlSurfaceTopViewWireframe; break;
default:
MsgBox(
"Incorrect Chart Type name : " + sChartTypeName,
Title: "ChartType_NameReturnType"
);
break;
}
ChartType_ReturnChartType = lreturn;
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
lreturn = 0;
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"ChartType_ReturnChartType",
msMODULENAME,
"return the corresponding chart type for '" + sChartTypeName + "'.",
mobjCOMException,
mobjException
);
}
}
return ChartType_ReturnChartType;
}
ChartSeries_Type_ReturnCategory
public string ChartSeries_Type_ReturnCategory(
Excel.Series objSeries)
{
try
{
if (clsError.ErrorFlag() == true)
{
return null;
}
switch (objSeries.ChartType)
{
case xlColumnClustered:
case xlColumnStacked:
case xlColumnStacked100:
case xl3DColumn:
case xl3DColumnClustered:
case xl3DColumnStacked:
case xl3DColumnStacked100:
ChartType_ReturnCategory = "Column";
break;
case xlBarClustered:
case xlBarStacked:
case xlBarStacked100:
case xl3DBarClustered:
case xl3DBarStacked:
case xl3DBarStacked100:
ChartType_ReturnCategory = "Bar";
break;
case xlLine:
case xlLineStacked:
case xlLineStacked100:
case xlLineMarkers:
case xlLineMarkersStacked:
case xlLineMarkersStacked100:
case xl3DLine:
ChartType_ReturnCategory = "Line";
break;
case xlBarOfPie:
case xlPie:
case xlPieExploded:
case xlPieOfPie:
case xl3DPie:
case xl3DPieExploded:
ChartType_ReturnCategory = "Pie";
break;
case xlXYScatter:
case xlXYScatterLines:
case xlXYScatterLinesNoMarkers:
case xlXYScatterSmooth:
case xlXYScatterSmoothNoMarkers:
ChartType_ReturnCategory = "Scatter";
break;
case xlArea:
case xlAreaStacked:
case xlAreaStacked100:
case xl3DArea:
case xl3DAreaStacked:
case xl3DAreaStacked100:
ChartType_ReturnCategory = "Area";
break;
case xlDoughnut:
case xlDoughnutExploded:
ChartType_ReturnCategory = "Doughnut";
break;
case xlRadar:
case xlRadarMarkers:
case xlRadarFilled:
ChartType_ReturnCategory = "Radar";
break;
case xlSurface:
case xlSurfaceTopView:
case xlSurfaceTopViewWireframe:
case xlSurfaceWireframe:
ChartType_ReturnCategory = "Surface";
break;
case xlBubble:
case xlBubble3DEffect:
ChartType_ReturnCategory = "Bubble";
break;
case xlStockHLC:
case xlStockVHLC:
case xlStockOHLC:
case xlStockVOHLC:
ChartType_ReturnCategory = "Stock";
break;
case xlCylinderBarClustered:
case xlCylinderBarStacked:
case xlCylinderBarStacked100:
case xlCylinderColClustered:
case xlCylinderColStacked:
case xlCylinderColStacked100:
ChartType_ReturnCategory = "Cylinder";
break;
case xlConeBarClustered:
case xlConeBarStacked:
case xlConeBarStacked100:
case xlConeColClustered:
case xlConeColStacked:
case xlConeColStacked100:
ChartType_ReturnCategory = "Cone";
break;
case xlPyramidCol:
case xlPyramidBarClustered:
case xlPyramidBarStacked:
case xlPyramidBarStacked100:
case xlPyramidColClustered:
case xlPyramidColStacked:
case xlPyramidColStacked100:
ChartType_ReturnCategory = "Pyramid";
break;
default:
MsgBox(
"Incorrect Chart Type number : " + objSeries.ChartType.ToString(),
Title: "Chart_TypeReturn"
);
break;
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
if (gbDEBUG == true ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"Chart_TypeReturn",
msMODULENAME,
"return the category name for the series '" + objSeries.Name + "'.",
mobjCOMException,
mobjException
);
}
}
return ChartType_ReturnCategory;
}
ChartSeries_Valid
public static bool ChartSeriesValid(
Excel.SeriesCollection objSeriesColl,
int iSeriesNo)
{
try
{
// an error occurs when the series number is valid but not plotted e.g. Pie Charts
Excel.Series objSeries;
objSeries = objSeriesColl.Item(iSeriesNo);
return true;
}
catch (System.Runtime.InteropServices.COMException)
{
return false;
}
}
ChartSource_DataPlotByGet
public string ChartSource_DataPlotByGet(
Excel.Chart objChart)
{
Excel.SeriesCollection objSeriesCol;
Excel.Series objSeries;
try
{
if (clsError.ErrorFlag() == true)
{
return null;
}
objSeriesCol = (Excel.SeriesCollection)objChart.SeriesCollection();
if (objSeriesCol.Count > 0)
{
objSeries = objSeriesCol.Item(1);
MsgBox(
"Series Values: " + ChartSeries_FormulaValuesGet(objSeries) +
"\r\n" +
"Series Labels: " + ChartSeries_FormulaLabelsGet(objSeries)
);
//Call MsgBox("Formula " & objSeries.Formula & vbCrLf & _
// "Formula Local " & objSeries.FormulaLocal & vbCrLf & _
// "Formula R1C1 " & objSeries.FormulaR1C1 & vbCrLf & _
// "Formula R1C1 Local " & objSeries.FormulaR1C1Local)
}
}
catch (System.Runtime.InteropServices.COMException objCOMException)
{
gobjCOMException = objCOMException;
}
catch (Exception objException)
{
gobjException = objException;
}
finally
{
objChart = null;
objSeriesCol = null;
objSeries = null;
if (gbDEBUG == true ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ChartSeries_SourceDataPlotByGet",
msMODULENAME,
"",
gobjCOMException,
gobjException
);
}
}
return null;
}
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited Top