>CREATE CURSOR testsub (date1 d(8),sno n(2),cash n(2),weight n(2)) >INSERT INTO testsub VALUES ({^2007/01/01},1,100,10) >INSERT INTO testsub VALUES ({^2007/01/01},2,150,20) >INSERT INTO testsub VALUES ({^2007/01/01},3,300,30) >INSERT INTO testsub VALUES ({^2007/01/02},4,200,40) >INSERT INTO testsub VALUES ({^2007/01/02},5,400,50) >INSERT INTO testsub VALUES ({^2007/01/02},6,300,60) >INSERT INTO testsub VALUES ({^2007/01/03},1,100,70) >>
>select testsub >copy to 'C:\Xls\'+alltrim("Date Wise")+".xls" type xl5 >release all like lo* >loexcel = createobject("Excel.Application") >loworkbook = loexcel.workbooks.open('C:\Xls\'+alltrim("Date Wise")+".xls") >losheet = loworkbook.sheets(1) && or pass the name of your sheet as a string! >loexcel.visible = .t. && display Excel >>Now In Excel Sheet, I want to get Sub Totals as
select space(10) as TotColumn, * from testub ; union all ; select 'Sub Total ' as TotColumn, date1, 00 as sno, ; sum(cash) as Cash, Sum(Weight) as Weight ; from TestSub group by Date1 ; order by Date1, sno desc into cursor curResultUse this cursor instead.