|
|
Re: merge cells in excel using ole2 [message #223179 is a reply to message #222669] |
Wed, 07 March 2007 21:15 |
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
|
|
|