Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. excel automation

excel automation

Scheduled Pinned Locked Moved C / C++ / MFC
sysadmintestingtoolsquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prithaa
    wrote on last edited by
    #1

    I am using automation classes to draw chart through excel from VC Is there any documetation where i can get the values of the variables to passed to ChartType Ex I have this code _Application app; _Workbook newBook; Workbooks books; Worksheets sheets; _Worksheet newSheet; Charts charts; _Chart newChart; COleVariant vOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR); //Create Excel server (start Excel) if(!app.CreateDispatch("Excel.Application")) { AfxMessageBox("Can’t start Excel server!"); return; } app.SetVisible(true); //set Excel visible // app.p.put_UserControl(TRUE); //user can operate Excel books = app.GetWorkbooks(); newBook=books.Open("d:\\wipro1.csv",vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt,vOpt, vOpt,vOpt,vOpt); sheets = newBook.GetSheets(); newSheet = sheets.GetItem(COleVariant((short)2)); charts = newBook.GetCharts(); newChart = charts.Add(vOpt,vOpt,COleVariant((short)1)); newChart.SetName("My chart"); newChart.SetChartType((long)1); --------------------------- The above code works fine but what variables should be passed to SetChartType ? which Variable corresponds to which charttype? Prithaa

    F 1 Reply Last reply
    0
    • P prithaa

      I am using automation classes to draw chart through excel from VC Is there any documetation where i can get the values of the variables to passed to ChartType Ex I have this code _Application app; _Workbook newBook; Workbooks books; Worksheets sheets; _Worksheet newSheet; Charts charts; _Chart newChart; COleVariant vOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR); //Create Excel server (start Excel) if(!app.CreateDispatch("Excel.Application")) { AfxMessageBox("Can’t start Excel server!"); return; } app.SetVisible(true); //set Excel visible // app.p.put_UserControl(TRUE); //user can operate Excel books = app.GetWorkbooks(); newBook=books.Open("d:\\wipro1.csv",vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt,vOpt, vOpt,vOpt,vOpt); sheets = newBook.GetSheets(); newSheet = sheets.GetItem(COleVariant((short)2)); charts = newBook.GetCharts(); newChart = charts.Add(vOpt,vOpt,COleVariant((short)1)); newChart.SetName("My chart"); newChart.SetChartType((long)1); --------------------------- The above code works fine but what variables should be passed to SetChartType ? which Variable corresponds to which charttype? Prithaa

      F Offline
      F Offline
      Franck Paquier
      wrote on last edited by
      #2

      good morning Here are the value for excel 12 ? well the values retrieved from Microsoft.Office.Interop.Excel.dll runtime version v1.1.4322 version 12.0.0.0 public enum XlChartType { xlXYScatter = -4169, xlRadar = -4151, xlDoughnut = -4120, xl3DPie = -4102, xl3DLine = -4101, xl3DColumn = -4100, xl3DArea = -4098, xlArea = 1, xlLine = 4, xlPie = 5, xlBubble = 15, xlColumnClustered = 51, xlColumnStacked = 52, xlColumnStacked100 = 53, xl3DColumnClustered = 54, xl3DColumnStacked = 55, xl3DColumnStacked100 = 56, xlBarClustered = 57, xlBarStacked = 58, xlBarStacked100 = 59, xl3DBarClustered = 60, xl3DBarStacked = 61, xl3DBarStacked100 = 62, xlLineStacked = 63, xlLineStacked100 = 64, xlLineMarkers = 65, xlLineMarkersStacked = 66, xlLineMarkersStacked100 = 67, xlPieOfPie = 68, xlPieExploded = 69, xl3DPieExploded = 70, xlBarOfPie = 71, xlXYScatterSmooth = 72, xlXYScatterSmoothNoMarkers = 73, xlXYScatterLines = 74, xlXYScatterLinesNoMarkers = 75, xlAreaStacked = 76, xlAreaStacked100 = 77, xl3DAreaStacked = 78, xl3DAreaStacked100 = 79, xlDoughnutExploded = 80, xlRadarMarkers = 81, xlRadarFilled = 82, xlSurface = 83, xlSurfaceWireframe = 84, xlSurfaceTopView = 85, xlSurfaceTopViewWireframe = 86, xlBubble3DEffect = 87, xlStockHLC = 88, xlStockOHLC = 89, xlStockVHLC = 90, xlStockVOHLC = 91, xlCylinderColClustered = 92, xlCylinderColStacked = 93, xlCylinderColStacked100 = 94, xlCylinderBarClustered = 95, xlCylinderBarStacked = 96, xlCylinderBarStacked100 = 97, xlCylinderCol = 98, xlConeColClustered = 99, xlConeColStacked = 100, xlConeColStacked100 = 101, xlConeBarClustered = 102, xlConeBarStacked = 103, xlConeBarStacked100 = 104, xlConeCol = 105, xlPyramidColClustered = 106, xlPyramidColStacked = 107, xlPyramidColStacked100 = 108, xlPyramidBarClustered = 109, xlPyramidBarStacked = 110, xlPyramidBarStacked100 = 111, xlPyramidCol = 112, } Regards Franck

      P 1 Reply Last reply
      0
      • F Franck Paquier

        good morning Here are the value for excel 12 ? well the values retrieved from Microsoft.Office.Interop.Excel.dll runtime version v1.1.4322 version 12.0.0.0 public enum XlChartType { xlXYScatter = -4169, xlRadar = -4151, xlDoughnut = -4120, xl3DPie = -4102, xl3DLine = -4101, xl3DColumn = -4100, xl3DArea = -4098, xlArea = 1, xlLine = 4, xlPie = 5, xlBubble = 15, xlColumnClustered = 51, xlColumnStacked = 52, xlColumnStacked100 = 53, xl3DColumnClustered = 54, xl3DColumnStacked = 55, xl3DColumnStacked100 = 56, xlBarClustered = 57, xlBarStacked = 58, xlBarStacked100 = 59, xl3DBarClustered = 60, xl3DBarStacked = 61, xl3DBarStacked100 = 62, xlLineStacked = 63, xlLineStacked100 = 64, xlLineMarkers = 65, xlLineMarkersStacked = 66, xlLineMarkersStacked100 = 67, xlPieOfPie = 68, xlPieExploded = 69, xl3DPieExploded = 70, xlBarOfPie = 71, xlXYScatterSmooth = 72, xlXYScatterSmoothNoMarkers = 73, xlXYScatterLines = 74, xlXYScatterLinesNoMarkers = 75, xlAreaStacked = 76, xlAreaStacked100 = 77, xl3DAreaStacked = 78, xl3DAreaStacked100 = 79, xlDoughnutExploded = 80, xlRadarMarkers = 81, xlRadarFilled = 82, xlSurface = 83, xlSurfaceWireframe = 84, xlSurfaceTopView = 85, xlSurfaceTopViewWireframe = 86, xlBubble3DEffect = 87, xlStockHLC = 88, xlStockOHLC = 89, xlStockVHLC = 90, xlStockVOHLC = 91, xlCylinderColClustered = 92, xlCylinderColStacked = 93, xlCylinderColStacked100 = 94, xlCylinderBarClustered = 95, xlCylinderBarStacked = 96, xlCylinderBarStacked100 = 97, xlCylinderCol = 98, xlConeColClustered = 99, xlConeColStacked = 100, xlConeColStacked100 = 101, xlConeBarClustered = 102, xlConeBarStacked = 103, xlConeBarStacked100 = 104, xlConeCol = 105, xlPyramidColClustered = 106, xlPyramidColStacked = 107, xlPyramidColStacked100 = 108, xlPyramidBarClustered = 109, xlPyramidBarStacked = 110, xlPyramidBarStacked100 = 111, xlPyramidCol = 112, } Regards Franck

        P Offline
        P Offline
        prithaa
        wrote on last edited by
        #3

        Hello, I have used the above chart types and to draw stock volume option xlStockVOHLC = 91 . The data is arranged properly in excel sheet but how to select data for the chart in columns i m using the following for data range _Chart newChart; Range oRang; oRang = newSheet.GetUsedRange() newChart.SetSourceData(oRang,COleVariant((short)1)); pritha

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups