>>IF .F. >> Perhaps you know how to do this. First create a cursor with string fields, some of which contain numbers as strings (for >> example " 5.00") and other contain formulas as strings (for example "=SUBTOTAL(9,H4:H10)") >> >> Next, send the cursor to Excel via ADODB as before. >> >> Now, how do you convert the strings to Excel numbers and formulas from VFP using automation? >>ENDIF >>>>
Select Cust_id, o.Order_id, Product_Id, Unit_price, Quantity ; > from (_samples+'data\orders') o inner Join (_samples+'data\orditems') oi On o.Order_id = oi.Order_id ; > order By Cust_id, o.Order_id ; > into Cursor myOrders > >Dimension laSubtotal[2] >laSubtotal[1] = 4 && Unit_price column >laSubtotal[2] = 5 && Quantity colum > >#include "xlConstants.h" >oExcel = Createobject("excel.application") >With oExcel > .Workbooks.Add > .Visible = .T. > * Place orders data 2 rows below Employee data > * and name the range as 'Orders' > PasteAtLocation(oExcel, 'myOrders','A1','Orders') > > *!* Subtotal grouping by customer then by order > With .ActiveWorkBook.ActiveSheet > .Range('A1').Select > .Range('Orders').Subtotal(1, xlSum, @laSubtotal) > .Range('Orders').Subtotal(2, xlSum, @laSubtotal,.F.,.F.,.F.) > .UsedRange.Columns.AutoFit > .Outline.ShowLevels(3) > Endwith >Endwith > >Function PasteAtLocation && Paste cursor content at given range and name the range > Lparameters toExcel, tcAlias, tcRange, tcRangeName > Local lcTemp,ix,lcHeaders > lcTemp = Sys(2015)+'.tmp' > Select (m.tcAlias) > Copy To (m.lcTemp) Type Delimited With "" With Tab > lcHeaders='' > For ix=1 To Fcount() > lcHeaders = m.lcHeaders + Iif(Empty(m.lcHeaders),'',Chr(9)) + Field(m.ix) > Endfor > _Cliptext = m.lcHeaders + Chr(13) + Chr(10) + Filetostr(m.lcTemp) > Erase (lcTemp) > With toExcel.ActiveWorkBook.ActiveSheet > .Range(m.tcRange).PasteSpecial() > toExcel.Selection.Name = m.tcRangeName > .Range(m.tcRangeName).Rows(1).Orientation = 90 > Endwith >Endfunc >Cetin