Home » Developer & Programmer » Forms » giving names to excel field ...
giving names to excel field ... [message #193603] Mon, 18 September 2006 07:46 Go to next message
whocracks
Messages: 4
Registered: August 2006
Junior Member
hiii all...

i have exported table records to excel sheet....running fine....
now i want to give column name to my excel book....i m using ole2 package...

can anybody give kines of code for this....plllzzzzzzzz....... help
Re: giving names to excel field ... [message #193608 is a reply to message #193603] Mon, 18 September 2006 07:54 Go to previous messageGo to next message
sandeepk7
Messages: 137
Registered: September 2006
Senior Member

can u post the current code what you are using?

Sandy
Re: giving names to excel field ... [message #193610 is a reply to message #193603] Mon, 18 September 2006 07:56 Go to previous messageGo to next message
whocracks
Messages: 4
Registered: August 2006
Junior Member
my code is as follows...
.....

declare
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
cell ole2.obj_type;
args ole2.list_type;
rowcount integer;
cursor c1 is select m_id,m_name,dept
from manager order by m_id;

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');

rowcount := 0;
for rec1 in c1 loop
rowcount := rowcount + 1;

args := ole2.create_arglist;
ole2.add_arg(args,rowcount);
ole2.add_arg(args,1);
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
ole2.set_property(cell,'Value',rec1.m_id);
ole2.release_obj(cell);


args := ole2.create_arglist;
ole2.add_arg(args,rowcount);
ole2.add_arg(args,2);
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
ole2.set_property(cell,'Value',rec1.m_name);
ole2.release_obj(cell);

args := ole2.create_arglist;
ole2.add_arg(args,rowcount);
ole2.add_arg(args,3);
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
ole2.set_property(cell,'Value',rec1.dept);
ole2.release_obj(cell);

end loop;


ole2.release_obj(worksheet);
ole2.release_obj(worksheets);
ole2.release_obj(workbook);
ole2.release_obj(workbooks);
ole2.release_obj(application);


end;

plz if u knw how to give column names to excel book... then send the code
Re: giving names to excel field ... [message #193677 is a reply to message #193610] Mon, 18 September 2006 23:19 Go to previous message
sandeepk7
Messages: 137
Registered: September 2006
Senior Member

Can't you make ur first row engage for headings and from second row your cursor will start flowing the data. like

declare
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
cell ole2.obj_type;
args ole2.list_type;
rowcount integer;
cursor c1 is select m_id,m_name,dept
from manager order by m_id;

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');

args := ole2.create_arglist;
ole2.add_arg(args,1);
ole2.add_arg(args,1);
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
ole2.set_property(cell,'Value','First Heading');
ole2.release_obj(cell);


args := ole2.create_arglist;
ole2.add_arg(args,1);
ole2.add_arg(args,2);
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
ole2.set_property(cell,'Value','Second Heading');
ole2.release_obj(cell);

args := ole2.create_arglist;
ole2.add_arg(args,1);
ole2.add_arg(args,3);
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
ole2.set_property(cell,'Value','Third Heading');
ole2.release_obj(cell);




rowcount := 1;
for rec1 in c1 loop
rowcount := rowcount + 1;

args := ole2.create_arglist;
ole2.add_arg(args,rowcount);
ole2.add_arg(args,1);
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
ole2.set_property(cell,'Value',rec1.m_id);
ole2.release_obj(cell);


args := ole2.create_arglist;
ole2.add_arg(args,rowcount);
ole2.add_arg(args,2);
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
ole2.set_property(cell,'Value',rec1.m_name);
ole2.release_obj(cell);

args := ole2.create_arglist;
ole2.add_arg(args,rowcount);
ole2.add_arg(args,3);
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
ole2.set_property(cell,'Value',rec1.dept);
ole2.release_obj(cell);

end loop;


ole2.release_obj(worksheet);
ole2.release_obj(worksheets);
ole2.release_obj(workbook);
ole2.release_obj(workbooks);
ole2.release_obj(application);


end;



Sandy
Previous Topic: Menu
Next Topic: reg:- when validate record
Goto Forum:
  


Current Time: Fri Dec 09 14:00:54 CST 2016

Total time taken to generate the page: 0.25297 seconds