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. How to Track the event in Excel for cell insert/delete in C++ or VC++ for ?

How to Track the event in Excel for cell insert/delete in C++ or VC++ for ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
10 Posts 3 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.
  • G Offline
    G Offline
    Gaurav1710
    wrote on last edited by
    #1

    Please can someone tell me how to track single/multiple cell insert/delete event in Excel. I have done with most of the events but fighting for this ? please suggest ..... We can add cells through context menu option (Right click) and Menu option ...but what are the events in C++ to catch this ...

    S 1 Reply Last reply
    0
    • G Gaurav1710

      Please can someone tell me how to track single/multiple cell insert/delete event in Excel. I have done with most of the events but fighting for this ? please suggest ..... We can add cells through context menu option (Right click) and Menu option ...but what are the events in C++ to catch this ...

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      The Workbook object has a 'SheetChange' event. The Worksheet object has a 'Change' event. Either of these will be fired if you change that worksheet.. So, if you have a workbook that contains Sheet1, Sheet2 and Sheet3, the SheetChange event of the workbook will be fired when ANY of Sheet1, Sheet2 and Sheet3 change. Sheet1 will fire the 'Change' event when it is changed. Sheet2 will fire the 'Change' event when it is changed. Sheet3 will fire the 'Change' event when it is changed. Simple as.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

      K 1 Reply Last reply
      0
      • S Stuart Dootson

        The Workbook object has a 'SheetChange' event. The Worksheet object has a 'Change' event. Either of these will be fired if you change that worksheet.. So, if you have a workbook that contains Sheet1, Sheet2 and Sheet3, the SheetChange event of the workbook will be fired when ANY of Sheet1, Sheet2 and Sheet3 change. Sheet1 will fire the 'Change' event when it is changed. Sheet2 will fire the 'Change' event when it is changed. Sheet3 will fire the 'Change' event when it is changed. Simple as.

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

        K Offline
        K Offline
        KTTransfer
        wrote on last edited by
        #3

        Hi Stuart, When cell is inserted, only cell where the new cell is inserted or deleted will be tracked in sheetchange event. But whereas the allignment of data cannot be tracked. For example: if following is the data before cell insert c0 c1 c2 c3 r0 1 2 3 4 r1 2 3 4 5 r2 3 4 5 6 If say I have inserted cell at r1c1 then the allignment of data after cell insert will be: c0 c1 c2 c3 c4 r0 1 2 3 4 r1 2 * 3 4 5 r2 3 4 5 6 * represents blank cell is inserted. How to track this change in allignment? For above example allignment change data will be:(r1c2:3,r1c3:4,r1c4:5) Following is the code in sheet change: _bstr_t result= target->GetAddress(1,1,Excel::XlReferenceStyle::xlR1C1,1,1); In result we are getting only r1c1. As of now we are able to do it when user inserts the cell using context menu: right click->insert, this we are tracking in sheetbeforerightclick, where we are setting the bool flag , and immediately in sheet change we are checking the same bool flag for true , if it is true then we are reading that complete row and complete col.But this will not work when user inserts/deletes the cell through menu. Please guide us to get this change in allingment of data for all the four options: cell insert/delete(shift cells right, shift cells down)/(shift cells up, shift cells left) when user inserts cell either through context menu or menu. Thanks in Advance, Regards, KTTransfer.

        S 1 Reply Last reply
        0
        • K KTTransfer

          Hi Stuart, When cell is inserted, only cell where the new cell is inserted or deleted will be tracked in sheetchange event. But whereas the allignment of data cannot be tracked. For example: if following is the data before cell insert c0 c1 c2 c3 r0 1 2 3 4 r1 2 3 4 5 r2 3 4 5 6 If say I have inserted cell at r1c1 then the allignment of data after cell insert will be: c0 c1 c2 c3 c4 r0 1 2 3 4 r1 2 * 3 4 5 r2 3 4 5 6 * represents blank cell is inserted. How to track this change in allignment? For above example allignment change data will be:(r1c2:3,r1c3:4,r1c4:5) Following is the code in sheet change: _bstr_t result= target->GetAddress(1,1,Excel::XlReferenceStyle::xlR1C1,1,1); In result we are getting only r1c1. As of now we are able to do it when user inserts the cell using context menu: right click->insert, this we are tracking in sheetbeforerightclick, where we are setting the bool flag , and immediately in sheet change we are checking the same bool flag for true , if it is true then we are reading that complete row and complete col.But this will not work when user inserts/deletes the cell through menu. Please guide us to get this change in allingment of data for all the four options: cell insert/delete(shift cells right, shift cells down)/(shift cells up, shift cells left) when user inserts cell either through context menu or menu. Thanks in Advance, Regards, KTTransfer.

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          It doesn't look like you can do that.... Which leads to the question WHY are you trying to track these changes? What's the higher level requirement? There is likely some other, better way of achieving what you really need....

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

          G 1 Reply Last reply
          0
          • S Stuart Dootson

            It doesn't look like you can do that.... Which leads to the question WHY are you trying to track these changes? What's the higher level requirement? There is likely some other, better way of achieving what you really need....

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

            G Offline
            G Offline
            Gaurav1710
            wrote on last edited by
            #5

            yes ..we need to track these changes for better optimization..If suppose somebody ass /deletes single /multiple cells in sheet then as described other cells will get shift to newer positions ..so we nned to update these changes to some server ...to be in sync with sheets ..but we dont want to send whole data from sheet again to server ..we just want to send latest updated cell ..so we need this event to track this cells...

            S 1 Reply Last reply
            0
            • G Gaurav1710

              yes ..we need to track these changes for better optimization..If suppose somebody ass /deletes single /multiple cells in sheet then as described other cells will get shift to newer positions ..so we nned to update these changes to some server ...to be in sync with sheets ..but we dont want to send whole data from sheet again to server ..we just want to send latest updated cell ..so we need this event to track this cells...

              S Offline
              S Offline
              Stuart Dootson
              wrote on last edited by
              #6

              Sounds like your optimisation strategy isn't feasible...

              Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

              G 1 Reply Last reply
              0
              • S Stuart Dootson

                Sounds like your optimisation strategy isn't feasible...

                Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

                G Offline
                G Offline
                Gaurav1710
                wrote on last edited by
                #7

                OK ..we have achived this in most of the events ..only this is missing ...anyways ..so according to u for this changes in sheet we need to send complete image of shet to server ? is that so ?

                S 1 Reply Last reply
                0
                • G Gaurav1710

                  OK ..we have achived this in most of the events ..only this is missing ...anyways ..so according to u for this changes in sheet we need to send complete image of shet to server ? is that so ?

                  S Offline
                  S Offline
                  Stuart Dootson
                  wrote on last edited by
                  #8

                  Probably the only reliable thing to do... How big are these worksheets that you need to optimise like this? Are you sure it's not premature optimisation...

                  Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

                  G 1 Reply Last reply
                  0
                  • S Stuart Dootson

                    Probably the only reliable thing to do... How big are these worksheets that you need to optimise like this? Are you sure it's not premature optimisation...

                    Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

                    G Offline
                    G Offline
                    Gaurav1710
                    wrote on last edited by
                    #9

                    these are very big sheets ..like one cell can contain 3K of data ..then you can assume the size of data we are passing to server ..so need this optimization ...and Its safe one

                    K 1 Reply Last reply
                    0
                    • G Gaurav1710

                      these are very big sheets ..like one cell can contain 3K of data ..then you can assume the size of data we are passing to server ..so need this optimization ...and Its safe one

                      K Offline
                      K Offline
                      KTTransfer
                      wrote on last edited by
                      #10

                      Hi Stuart, Is there any chance to track the "menu" selected by user in Excel Menu Items. If we get this, then we can achieve tracking allignment of data? Regards, KTTransfer.

                      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