Recent

Author Topic: office automation??  (Read 40076 times)

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: office automation??
« Reply #15 on: August 11, 2009, 04:30:44 pm »
Import them with the delphi tool or ask a friend to do that for you ;-)

Or read here: http://forum.lazarus.freepascal.org/index.php?topic=5471.0

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #16 on: August 11, 2009, 07:01:12 pm »
so, is there any avaliable way to automate office procedures today in lazarus?
 :o

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: office automation??
« Reply #17 on: August 11, 2009, 07:11:50 pm »
Import them with the delphi tool or ask a friend to do that for you ;-)

Or read here: http://forum.lazarus.freepascal.org/index.php?topic=5471.0

CreateOleObject uses late binding so no type library is required as with early binding.

Thales: I would assume for now that Automation does not work with FPC and move on.

If you just need to display a document or spreadsheet, you can do that just by shelling to it.

Thanks.

-Phil

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #18 on: August 11, 2009, 08:20:40 pm »
I would assume for now that Automation does not work with FPC and move on.

If you just need to display a document or spreadsheet, you can do that just by shelling to it.

Thanks.

-Phil

nice...
and, no, i dont want to display it...
i just found more convenient to automate an excel document with reports, charts, etc. instead of generating lazreports...

thanks for the help!

THALES VAZ

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: office automation??
« Reply #19 on: August 11, 2009, 08:28:16 pm »
nice...
and, no, i dont want to display it...
i just found more convenient to automate an excel document with reports, charts, etc. instead of generating lazreports...

thanks for the help!

THALES VAZ

Again, I know this has been repeated many times, but doing Automation would only be for Windows and never for OS X or Linux. If you're only doing Windows, why not stay with Delphi, where that works great? Kind of the whole point of Lazarus and Free Pascal is cross-platform. Using them only on Windows is like buying a bicycle with fat tires and aggressive tread, but oh, no, I'll never leave the pavement...

Thanks.

-Phil

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #20 on: August 11, 2009, 10:09:39 pm »
Again, I know this has been repeated many times, but doing Automation would only be for Windows and never for OS X or Linux. If you're only doing Windows, why not stay with Delphi, where that works great? Kind of the whole point of Lazarus and Free Pascal is cross-platform. Using them only on Windows is like buying a bicycle with fat tires and aggressive tread, but oh, no, I'll never leave the pavement...

good question!
actually, this is because people have to pay for delphi...
since lazarus is free, well...
sounds weird, but as i dont mind sharing ideas and code with people, i think that's ok to use o free ide to make commercial software, right? :)

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: office automation??
« Reply #21 on: August 11, 2009, 10:25:50 pm »
The Turbos are free, but I don't know how much support for your purpose they have:
https://downloads.embarcadero.com/free/delphi

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #22 on: August 12, 2009, 01:18:22 pm »
i'm not sure about that, because i downloaded turbo delphi 2006 and it is a 300MB file... and you also have to download and install .net framework and .net framework sdk (there are also other stuff...)
which is kinda heavy as hell!!! >:D

regards

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: office automation??
« Reply #23 on: August 12, 2009, 03:14:52 pm »
What exactly do you need to do?

To read, modify and write spreadsheet files you can use FPSpreadsheet (substitutes Excel or OO Calc automation for most uses):

http://wiki.lazarus.freepascal.org/FPSpreadsheet

To read, modify and write vectorial graphics you can use FPVectorial (substitutes OpenOffice Draw automation for most uses):

http://wiki.lazarus.freepascal.org/fpvectorial

So the only thing missing is read/modify/write text documents. For this I think there is a RTF component somewhere which could substitute Word automation in some cases.

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #24 on: August 12, 2009, 04:22:09 pm »
What exactly do you need to do?

automate office procedures the same way as in delphi, where you'd use automation servers provided with msoffice...
but, i'll try fpspreadsheet...
already downloaded the chm file, but i'm not sure how to use that component...
 :o
thanks

THALES VAZ
« Last Edit: August 12, 2009, 04:30:07 pm by thales »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: office automation??
« Reply #25 on: August 13, 2009, 02:09:16 am »
Yes, but which specific tasks do you want to perform? "automating" is very unspecific, it could mean any of the 1000s of tasks which can be acomplished with office

thales

  • New Member
  • *
  • Posts: 21
Re: office automation??
« Reply #26 on: August 13, 2009, 01:18:43 pm »
so, what i wanted to do is to get a open dataset (some query result...) and put it into excel... and then build the report there (automatically) where it should place a bmp with the logo of something, a title (in the first row and also making that first row the header for all pages), build charts, specify page setup, etc...
so, lots of automatable office stuff...
would you like me to put here some examples?

THALES VAZ

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: office automation??
« Reply #27 on: August 16, 2009, 04:56:00 am »
A lot is missing from fpspreadsheet to be able to do that ... loading from a TDataset, report generation, charts, etc.

gakusei

  • Newbie
  • Posts: 2
Re: office automation??
« Reply #28 on: November 07, 2009, 10:14:53 am »
thales, sure you can automate office apps using FPC, but the process wil be more like raw C code, not Delphi-like. If you want more info on OLE stuff - PM me or dig in MSDN  ;)

gakusei

  • Newbie
  • Posts: 2
Re: office automation??
« Reply #29 on: November 07, 2009, 03:43:08 pm »
Here's little and dirty example of OLE automation done in raw WinAPI

Code: [Select]
program oletest;

{$APPTYPE CONSOLE}

uses
  SysUtils, Windows, ActiveX, Ole2;

var
  unkXl: IUnknown;
  dispXl: IDispatch;
  clsidXl: TCLSID;
  did: TDispID;
  name: POleStr;
  dps: DISPPARAMS;
  didNamed: TDispID;
  param: VARIANTARG;
  hres: HRESULT;
begin
  // initialize COM
  CoInitialize(nil);
  // get CLSID of Excel
  CLSIDFromProgID('Excel.Application', clsidXl);
  // create Excel instance
  CoCreateInstance(clsidXl, nil, CLSCTX_LOCAL_SERVER, IID_IUnknown, unkXl);
  // get IDispatch interface of received object
  unkXl.QueryInterface(IID_IDispatch, dispXl);

  // DO SOME STUFF WITH EXCEL HERE
  // for example, we'll just show it ;)
  name:= 'Visible';
  param.vt:= VT_BOOL;
  param.vbool:= true;
  dps.cArgs:= 1;
  dps.rgvarg:= @param;
  didNamed:= DISPID_PROPERTYPUT;
  dps.cNamedArgs:= 1;
  dps.rgdispidNamedArgs:= @didNamed;

  dispXl.GetIDsOfNames(GUID_NULL, @name, 1, LOCALE_SYSTEM_DEFAULT, @did);
  hres:= dispXl.Invoke(did, GUID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT,
    dps, nil, nil, nil);

  MessageBox(0, 'Hit OK to end the app', 'Test', MB_OK or MB_ICONINFORMATION);


  // release unused objects
  dispXl.Release;
  unkXl.Release;
  // deinitialize COM
  CoUninitialize;
end.

 

TinyPortal © 2005-2018