Good Afternon Milind,
> In a form dabase is opened in grid mode with certain fields and with a filter condition . Field headings are changed. Is there any way to export this data set excel ?
Yes it is possible. You will have to check Ken's books for expamples of
this.
I export to csv which can be opened in excel very easily.
The code that I use
out_file = putfile( "Export the Inventory to ", "", "CSV", true )
if not empty(out_file)
fout = new file()
fout.create(out_file,"A")
cstr = [Bcode,Company,Item,Descrip,Mrp,Discount ,Nett
Rate,Head
Office,]+mcompany.go1+[,]+mcompany.go2+[,unit,gst,continue,generic,clearance,cr
date,lp_date]
fout.writeln(cstr)
form.linvedatamodule1.inve_dbf1.rowset.first()
a = form.linvedatamodule1.inve_dbf1.rowset.fields
do while not form.linvedatamodule1.inve_dbf1.rowset.endofset
cstr = [" ]+alltrim(a["bcode"].value)
cstr+= [","] + alltrim(a["company"].value)
cstr+= [","] + alltrim(a["item"].value)
cstr+= [","]+ alltrim(a["descrip"].value)
cstr+= [",]+ str(a["mrp"].value,14,2)
cstr+= [,] +a["disc"].value+[%,]+ a["nett"].value
cstr+= [,] +a["hoqty"].value+[,]+ a["go1qty"].value
cstr+= [,] +a["go2qty"].value+[,"]+ alltrim(a["unit"].value)
cstr+= [","] +a["gst"].value+[","]+ a["conti"].value
cstr+= [","] +a["generi"].value+[","]+
yes_no(a["clearance"].value)
cstr+= [","] +alltrim(dtoc(a["cr_date"].value))
cstr+= [","] +alltrim(dtoc(a["lp_date"].value))+["]
fout.writeln(cstr)
form.linvedatamodule1.inve_dbf1.rowset.next()
enddo
fout.close()
endif
Watch for word warp in some lines.
Alter it to suit your needs.
Regards
Akshat
|