LitDev.Engines.GraphEngine.mnuExcel_Click C# (CSharp) Method

mnuExcel_Click() private method

private mnuExcel_Click ( Object sender, EventArgs e ) : void
sender Object
e System.EventArgs
return void
        private void mnuExcel_Click(Object sender, EventArgs e)
        {
            try
            {
                MenuItem _item = (MenuItem)sender;
                Canvas _graph = (Canvas)_item.Tag;
                plotData _plotData = getPlotData((string)_graph.Tag);

                object misValue = System.Reflection.Missing.Value;

                Excel.Application xlApp = new Excel.Application();
                Excel.Workbook xlWorkBook = xlApp.Workbooks.Add(misValue);
                Excel.Worksheet xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

                xlApp.Visible = true;

                if (_plotData.title.Length > 0) xlWorkSheet.Name = _plotData.title;

                for (int i = 0; i < _plotData.series.Count; i++)
                {
                    xlWorkSheet.Cells[1, 1 + 3 * i] = _plotData.series[i].name;
                    xlWorkSheet.Cells[2, 1 + 3 * i] = _plotData.labelX;
                    xlWorkSheet.Cells[2, 2 + 3 * i] = _plotData.labelY;
                    for (int j = 0; j < _plotData.series[i].dataX.Count; j++)
                    {
                        xlWorkSheet.Cells[4 + j, 1 + 3 * i] = _plotData.series[i].dataX[j];
                        xlWorkSheet.Cells[4 + j, 2 + 3 * i] = _plotData.series[i].dataY[j];
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
        }