Originally posted by Ed Merritt
View Post
flds = "MerchantFulfillmentOrderID"+","+..............
Alpha Software Mobile Development Tools: Alpha Anywhere | Alpha TransForm | ![]() ![]() ![]() ![]() |
flds = strtran(lower(tbl.field_name_get()),crlf(),",")'writes all field names
dim tbl as P tbl = table.open("fba_details") flds = strtran(lower(tbl.field_name_get()),crlf(),",")'writes all field names file_pointer = file.create("c:\output.txt", FILE_RW_EXCLUSIVE) tbl.fetch_first() file_pointer.write_line(flds) while .NOT. tbl.fetch_eof() towrite = alltrim(tbl.Merchantfu)+"," towrite = towrite + alltrim(tbl.Displayabl)+"," towrite = towrite + alltrim(tbl.Displayab0)+"," towrite = towrite + alltrim(tbl.Merchantsk)+"," towrite = towrite + alltrim(str(tbl.Quantity,8))+"," towrite = towrite + alltrim(tbl.Merchantf0)+"," towrite = towrite + alltrim(tbl.Giftmessag)+"," towrite = towrite + alltrim(tbl.Displayab1)+"," towrite = towrite + alltrim(str(tbl.Perunitdec,8,2))+"," towrite = towrite + alltrim(tbl.Displayab2)+"," towrite = towrite + alltrim(tbl.Deliverysl)+"," towrite = towrite + alltrim(tbl.Addressnam)+"," towrite = towrite + alltrim(tbl.Addressfie)+"," towrite = towrite + alltrim(tbl.Addressfi0)+"," towrite = towrite + alltrim(tbl.Addressfi1)+"," towrite = towrite + alltrim(tbl.Addresscit)+"," towrite = towrite + alltrim(tbl.Addresscou)+"," towrite = towrite + alltrim(tbl.Addresssta)+"," towrite = towrite + alltrim(tbl.Addresspos)+"," towrite = towrite + alltrim(tbl.Addresspho)+"," towrite = towrite + alltrim(tbl.Notificati)+"," towrite = towrite + alltrim(convert_type(tbl.Successful,"C"))+"," towrite = towrite + alltrim(tbl.Orderdetai) file_pointer.write_line(towrite) tbl.fetch_next() end while file_pointer.flush() file_pointer.close() tbl.close()
FUNCTION ex_lowcase AS L (excelname AS C, newname AS C ) ex_lowcase = .F. Dim xlApp as p dim myCell as c xlApp = ole.create("Excel.Application") xlApp.Workbooks.Open(excelname) 'xlApp.Visible = .T. 'comment this line out if you don't want to see Excel IF xlApp.ActiveWorkbook.ReadOnly ui_msg_box("Alert","Halting because file is read-only.",UI_OK) xlapp.DisplayAlerts = .F. xlApp.Workbooks.Close() xlapp.DisplayAlerts = .T. xlApp.Quit() delete xlApp exit function END IF 'establish last row value lastrow = xlApp.Activecell.SpecialCells("11").Row lastcol = xlApp.Activecell.SpecialCells("11").Column lastcell = xlindx_to_txt(lastcol)+lastrow lasthead = xlindx_to_txt(lastcol)+1 xlApp.Rows("1:1").Select() xlApp.Selection.Insert(-4121) for qx = 1 to lastcol xlApp.Cells(1,qx).Select() xlApp.ActiveCell.FormulaR1C1 = "=LOWER(R[1]C)" next qx xlApp.Range("A1:"+lasthead).Select() xlApp.Application.CutCopyMode = .F. xlApp.Selection.Copy() xlApp.Range("A1").Select() xlApp.Selection.PasteSpecial(-4163,-4142,.F.,.F.) XlApp.Rows("2:2").Select() xlApp.Application.CutCopyMode = .F. xlApp.Selection.Delete(-4162) xlApp.Range("A1:"+lastcell).Select() xlapp.DisplayAlerts = .F. xlApp.ActiveWorkbook.SaveAs(newname,-4143) '33 is a constant for Excel 4.0, dbf4 is 11 xlApp.Workbooks.Close() xlapp.DisplayAlerts = .T. xlApp.Quit() ex_lowcase = .T. END FUNCTION FUNCTION xlindx_to_txt AS C (colnum AS N ) If Colnum > 26 Then xlindx_to_txt = Chr(Int((Colnum - 1) / 26) + 64) + Chr((mod((Colnum - 1),26) ) + 65) Else xlindx_to_txt = Chr(Colnum + 64) End If END FUNCTION
export_filename = "fba_export2.txt" a_tbl = table.open("fba_details") ON ERROR GOTO ERROR1102201115316500 DIM a5_operation_order as C a5_operation_order = "Displayableorderid" query.order = a5_operation_order DIM a5_operation_filter as C a5_operation_filter = "Successful_Upload=.F." query.filter = a5_operation_filter query.options = "I" query.Description = "Temporary Query" i_indx = a_tbl.query_create() export.type = 0 export.names = .T. export.file = export_filename export.options = "" export.field_sep = " " export.record_sep = "<CR><LF>" export.fields = 21 export.field1 = "merchantfulfillmentorderid" export.field2 = "displayableorderid" export.field3 = "displayableorderdate" export.field4 = "merchantsku" export.field5 = "quantity" export.field6 = "merchantfulfillmentorderitemid" export.field7 = "giftmessage" export.field8 = "displayablecomment" export.field9 = "perunitdeclaredvalue" export.field10 = "displayableordercomment" export.field11 = "deliverysla" export.field12 = "addressname" export.field13 = "addressfieldone" export.field14 = "addressfieldtwo" export.field15 = "addressfieldthree" export.field16 = "addresscity" export.field17 = "addresscountrycode" export.field18 = "addressstateorregion" export.field19 = "addresspostalcode" export.field20 = "addressphonenumber" export.field21 = "notificationsemail" a_tbl.export() GOTO CONTINUE1102201115316500 ERROR1102201115316500: ON ERROR GOTO 0 ui_msg_box("Error","Error running Export Operation"+crlf()+error_text_get()) END CONTINUE1102201115316500: a_tbl.close()
dim tbl as P tbl = table.open("[COLOR="Red"]c:\a5\a_sports\customer.dbf[/COLOR]") flds = strtran(lower(tbl.field_name_get()),crlf(),",")'writes all field names ' or flds ="firstname,lastname" 'for example file_pointer = file.create("c:\a5\output.txt", FILE_RW_EXCLUSIVE) tbl.fetch_first() file_pointer.write_line(flds) while .NOT. tbl.fetch_eof() file_pointer.write_line([COLOR="RoyalBlue"]tbl.first_name - " " + tbl.last_name[/COLOR]) tbl.fetch_next() end while file_pointer.flush() file_pointer.close() tbl.close()
Leave a comment: