Home » Developer & Programmer » Forms » merge cells in excel using ole2
merge cells in excel using ole2 [message #222669] Mon, 05 March 2007 20:19 Go to next message
ekim0410
Messages: 4
Registered: September 2006
Junior Member
im developing a procedure that will write data on excel file in forms 6i. Does anyone know how to merge cells using ole2? thanks.
Re: merge cells in excel using ole2 [message #222909 is a reply to message #222669] Tue, 06 March 2007 23:20 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

Try this one: http://www.tek-tips.com/viewthread.cfm?qid=468193
Re: merge cells in excel using ole2 [message #223179 is a reply to message #222669] Wed, 07 March 2007 21:15 Go to previous message
ekim0410
Messages: 4
Registered: September 2006
Junior Member
thanks man! the link you sent helped me.

for those who want the sample code for merging cells here it is:
/*merge columns f:h, rows 1:5*/
DECLARE
application OLE2.OBJ_TYPE;
workbook OLE2.OBJ_TYPE;
workbooks OLE2.OBJ_TYPE;
worksheet OLE2.OBJ_TYPE;
worksheets OLE2.OBJ_TYPE;
cell OLE2.OBJ_TYPE;
column OLE2.OBJ_TYPE;
row OLE2.OBJ_TYPE;
args OLE2.List_Type;
BEGIN
application := OLE2.CREATE_OBJ('Excel.Application');
OLE2.SET_PROPERTY(application, 'Visible', 'True');
workbooks := OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');
workbook := OLE2.INVOKE_OBJ(workbooks,'Add');

worksheets := OLE2.GET_OBJ_PROPERTY(workbook, 'Worksheets');
worksheet := OLE2.INVOKE_OBJ(worksheets,'Add');

--get the columns to merge
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'F:H'); --Columns F thru H
column := OLE2.GET_OBJ_PROPERTY(worksheet, 'Columns', args);
OLE2.DESTROY_ARGLIST(args);

--get the rows of the columns to merge
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, '1:5'); --Rows 1 thru 5
row := OLE2.GET_OBJ_PROPERTY(column, 'Rows', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.INVOKE(row, 'Merge');

OLE2.RELEASE_OBJ(row);
OLE2.RELEASE_OBJ(column);
OLE2.RELEASE_OBJ(worksheet);
OLE2.RELEASE_OBJ(worksheets);
OLE2.RELEASE_OBJ(workbook);
OLE2.RELEASE_OBJ(workbooks);
OLE2.RELEASE_OBJ(application);
EXCEPTION
WHEN others THEN
OLE2.Release_Obj( application );
message('Error');
END;


[Updated on: Wed, 07 March 2007 21:16]

Report message to a moderator

Previous Topic: Multiple text item problem!
Next Topic: regarding form size(URGENT)
Goto Forum:
  


Current Time: Sat Dec 03 12:14:05 CST 2016

Total time taken to generate the page: 0.15932 seconds