ActiveX control required to insert Excel into dialog

I create an import from Excel function. It must be in a DLL called from an application other than MFC. Must provide an image of the spreadsheet so that users can drag the selection box (to select cells), then click on the “IMPORT” button and do the right job. Failed to get the table by clicking the button next to it and getting it in the DLL.

I followed the path of the MFC dialog inside the DLL, but was blocked trying to call the OLE client for Excel in a window in a dialog box. Only the support I found to display Excel using OLE required SDI. I was able to get the automation functions to work, and I could read the cells and paint them with a "fake image" in my dialog box ... but I am afraid that this will not meet my requirements.

So I tried to create an SDI. I was able to create an SDI that cited Excel as an OLE client. I was able to handle the "change change" event and navigate to the cell data that I need. I was frustrated at this point by two points:

  • Failed to get this SDI to work in the MFC DLL. CWinApp constructor crashes, claiming AfxGetThread was not null. The moved "theApp" was locally localized inside one exported DLL function, but still could not get it to work, but with different symptoms: crash when adding AFX_MANAGE_STATE (AfxGetStaticModuleState ()); for the exported DLL function, if I did not use this, OnInitInstance was never entered. I tried to add a call to the Run () function of the application, but this did not help. I can post this code if someone thinks they have an idea what the problem is.

  • It is not possible to present a toolbar while an Excel client item is active. I could put my “import” (and other options) in the menu bar at the top, but this is not obvious enough. Even the floating toolbar was closed. It makes sense that he will do this, since it would be strange to have a toolbar that could not take action on the current active element ... but in my case this is a problem.

So, now I think that I need to go back to the dialog approach and implement the ActiveX control, which causes the import of the Excel spreadsheet file.

It should either allow me to handle the selection change event, or let me find which cells are selected (or were the last to be selected if I click the "import" button in my dialog box so that the selected cells become inaccessible).

, , .

- " " , , .

, - !

+5
1

Excel, .

OCX.

0

All Articles