-2

Years ago I remember installing excel and office components onto the component palette in delphi 5. It was either through activeX or COM, or a typelib, there was some way to install the components. the components I think you could drag and drop onto the form and then a spreadsheet would be embedded into your app (or microsoft word, etc.).

The only information I can find on the internet is about using OLEcontainers... which is a component in the system tab of delphi 5. However I do not remember it being an OLEcontainer when I used components for embedding excel, I rather remember installing actual excel and office components onto the component palette somehow... the components may have been generated from an ocx file or a typelib, I do not remember. Where does one find or obtain the files to generate the excel and office components on the component palette? are they ocx and do they come with my copy of MS Office that I have on my computer?

Are there excel COM or activex components that one can install? Am I remembering correctly, or is the only way to use excel through OLEcontainer component?

Edit: it may have also been an automation server component for excel or office

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
Another Prog
  • 841
  • 13
  • 19
  • 2
    Your memory is wrong, and the answer you've posted does not match the question you've asked. The type library import can create items in the component palette, but none of them allow you to embed an actual spreadsheet on your form. They allow automation of the various Office apps, but not embedding them. The *only* way to embed an actual spreadsheet on your form and use Excel's menus and formulas (without purchasing a third-party library) is via an OLE container. Also, Delphi has included components for Office in its install (via a package and the type library) for a decade now. – Ken White Mar 28 '15 at 22:17
  • Perhaps you don't understand what the term "embed" really means. It would take an extreme load of trickery for one to be able to accomplish such a thing, even if it was technically possible.Embedding just the Excel window, maybe. But embedding the toolbar separately too, that's not how Excel was designed. – Jerry Dodge Mar 28 '15 at 23:54
  • Jerry Dodge, perhaps you miss the whole point of COM and OLE and ActiveX. Do you know what OLE stands for? Object linking and embedding. OLE is all about linking and embedding objects such as excel spreadsheets into another foreign application. No trickery required. – Another Prog Mar 29 '15 at 00:24

2 Answers2

3

You can do this:

In FormCreate (or OnActivate..)

OleContainer1.CreateLinkToFile( Edit1.Text, false );

This is the result:

Result

Hexfire
  • 5,945
  • 8
  • 32
  • 42
-1

Figured out how to at least import the excel components into delphi component palette (but these are not for embedding spreadsheet). Many people click "import activex control" but that will not import an excel spreadsheet component since the excel components are a type library import.

You cannot import the excel activex control the way you would think using "import activex control" menu item, rather you can import the type library instead.

Go to the main menu and click Project -- Import Type Library

Scroll down and find Microsoft Excel 14.0

(or whatever version of excel you have...)

then install.

The components appear on the component palette under activex tab.

Those are for automation. For OLE embedding, it seems that Ole container is the way to go.

Another Prog
  • 841
  • 13
  • 19