locked
Grouped Charts Excel c# RRS feed

  • Question

  • Hello,

    I have some trouble with grouped chart.
    I tried to copy a grouped chart from excel in c#.
    Each chart and grouped chart have specific names 
    As you will see in my code I can found no-grouped chart and I copy it on word with pasteSpecial.
    But I can't found the grouped chart name.

    He is my code :

      foreach (Excel.Worksheet sheet in Globals.ThisAddIn.Application.Sheets)
                                {               
     
                                    foreach (Excel.ChartObject chart in sheet.ChartObjects(Type.Missing))
                                    {
                                        //Console.WriteLine(chart.Chart.ChartGroups().Count + " name = " + chart.Name);
                                        if (myrange.Find.Execute(Table_List[i]))
                                        {
                                            chart.Chart.ChartArea.Copy();
                                            myrange.PasteSpecial(DataType: Word.WdPasteDataType.wdPasteBitmap);
                                        }
    
                                        //Console.WriteLine(chart.Chart.);
                                    }
                                }


    Many thanks


    • Edited by Descostes Tuesday, September 20, 2016 1:40 PM update
    Tuesday, September 20, 2016 1:32 PM

Answers

  • >>>As you will see in my code I can found no-grouped chart and I copy it on word with pasteSpecial.
    But I can't found the grouped chart name.<<<

    According to your description, you could refer to below code:

    Globals.ThisAddIn.Application.ActiveSheet.Shapes.Range["chartsGroup"].Select();
    Globals.ThisAddIn.Application.Selection.Copy();
    
    Word.Application wordApp = new Word.Application();
    wordApp.Visible = true;
    Word.Document doc = wordApp.Documents.Add();
    wordApp.Selection.PasteSpecial(DataType: Word.WdPasteDataType.wdPasteBitmap);

    The result:



    Thanks for your understanding.

    • Marked as answer by Descostes Wednesday, September 21, 2016 3:04 PM
    Wednesday, September 21, 2016 5:42 AM

All replies

  • >>>As you will see in my code I can found no-grouped chart and I copy it on word with pasteSpecial.
    But I can't found the grouped chart name.<<<

    According to your description, you could refer to below code:

    Globals.ThisAddIn.Application.ActiveSheet.Shapes.Range["chartsGroup"].Select();
    Globals.ThisAddIn.Application.Selection.Copy();
    
    Word.Application wordApp = new Word.Application();
    wordApp.Visible = true;
    Word.Document doc = wordApp.Documents.Add();
    wordApp.Selection.PasteSpecial(DataType: Word.WdPasteDataType.wdPasteBitmap);

    The result:



    Thanks for your understanding.

    • Marked as answer by Descostes Wednesday, September 21, 2016 3:04 PM
    Wednesday, September 21, 2016 5:42 AM
  • Thanks !
    Wednesday, September 21, 2016 3:04 PM