Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OLE2 Excel Again! 1

Status
Not open for further replies.

mashtiani

IS-IT--Management
Apr 5, 2001
4
US
Hi All,
I am unable to format a cell or add a style to a cell.
say I want to fromat a cell for $###.###.## and make it cetered or right aligned. I appriciate any help I can get thanks
 
Here is an example:

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;

args OLE2.List_Type;

xlLeft CONSTANT number(4) := -4131;
xlCenter CONSTANT number(4) := -4108;
xlRight CONSTANT number(4) := -4152;
xlTop CONSTANT number(4) := -4160;
xlBottom CONSTANT number(4) := -4107;
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');

--Set cell B4
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 4);
OLE2.ADD_ARG(args, 'B');
cell := OLE2.GET_OBJ_PROPERTY(worksheet, 'Cells', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.SET_PROPERTY(cell, 'Value', 123456.78);
OLE2.SET_PROPERTY(cell, 'NumberFormat', '$###,##0.00');
OLE2.SET_PROPERTY(cell, 'HorizontalAlignment', xlLeft );
OLE2.SET_PROPERTY(cell, 'VerticalAlignment', xlTop );
OLE2.SET_PROPERTY(cell, 'RowHeight', 40);
OLE2.SET_PROPERTY(cell, 'ColumnWidth', 25);
OLE2.RELEASE_OBJ(cell);

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('errors');
END;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top