Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I need to convert dbf to html
Message
 
To
07/04/2017 05:20:38
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
01649884
Message ID:
01649934
Views:
30
>>>>I just need an example of code then I can take it from there
>>>
>>>I can expand on the example I already posted (below)
>>>
>>>Please point out what's unclear to you -- specifically
>>>
>>>
>>>cFile = 'some address'
>>>use table
>>>nField = fcount()
>>>strtofile('', m.cFile)
>>>strtofile('<table>' + chr(13) + chr(10), m.cFile, 1)
>>>strtofile('<tbody>' + chr(13) + chr(10), m.cFile, 1)
>>>scan
>>>  strtofile('<tr>', m.cFile, 1)
>>>  for iField = 1 to m.nField
>>>    strtofile('<td>' + trim(eval(field(m.iField))) + '</td>', m.cFile, 1)
>>
>>>  endfor
>>>  strtofile('</tr>' + chr(13) + chr(10), m.cFile, 1)
>>>endscan
>>>strtofile('</tbody>' + chr(13) + chr(10), m.cFile, 1)
>>>strtofile('</table>' + chr(13) + chr(10), m.cFile, 1)
>>>
>>
>>
>>
>>Thanks for that
>>
>>Colin
>
>Here's a program I wrote for my own need many years ago. I don't use it anymore, and I am sure that the code can be optimized quite a bit. But it works...! :-)
>
>To use it, use the syntax strtofile(cur2htm('yourtable'),'yourpath\yourfile.htm').
>
>
*Cur2htm.prg
>Lparameters lxAlias,lxHBGColor, lxRow2Color, lxHFGColor 
>Local lcHtml, lnFields, lnRecord
>#define crlf Chr(13)+Chr(10)
>If InList(Vartype(lxAlias),'N','C') 
>  If Used(lxAlias)
>    Select (lxAlias)
>  Else 
>    Return ''
>  EndIf 
>Else 
>  If Empty(Alias())
>    Return ''
>  EndIf  
>EndIf 
>If Pcount()>1 and Vartype(lxHBGColor)#'L'
>  If Vartype(lxHBGColor)='N'
>    lxHBGColor=num2webcolor(lxHBGColor,1)
>  Else 
>    lxHBGColor='#' + Chrtran(lxHBGColor,'#','')
>  EndIf 
>Else 
>  lxHBGColor='#CCCCFF'
>EndIf 
>If Pcount()>2 and Vartype(lxRow2Color)#'L'
>  If Vartype(lxRow2Color)='N'
>    lxRow2Color=num2webcolor(lxRow2Color,1)
>  Else 
>    lxRow2Color='#' + Chrtran(lxRow2Color,'#','')
>  EndIf 
>Else 
>  lxRow2Color='#EEEEEE'
>EndIf 
>If Pcount()>3 and Vartype(lxHFGColor)#'L'
>  If Vartype(lxHFGColor)='N'
>    lxHFGColor=num2webcolor(lxHFGColor,1)
>  Else 
>    lxHFGColor='#' + Chrtran(lxHFGColor,'#','')
>  EndIf 
>Else 
>  lxHFGColor='DarkBlue'
>EndIf 
>   
>lnRecord=1
>lcHtml = '<CENTER>'
>lcHtml = lcHtml + '<TABLE  BGCOLOR="' + lxHBGColor + '" CELLPADDING="3" CELLSPACING="0" BORDER="1"  WIDTH="98%" style="font:normal normal 10pt Verdana;border-collapse:collapse;border-color:lightgray">' + crlf
>lcHtml = lcHtml + '<TR BGCOLOR="' + lxHFGColor + '">'
>lnFields=AFields(flist)
>For x=1 to lnFields
>  lcHtml = lcHtml + '<TH style="font-family:Verdana,Helvetica;color:White">' + Proper(Field(x)) + '</TH>'
>EndFor 
>lcHtml = lcHtml + '</TR>' + crlf
>Scan 
>  If lnRecord%2=0
>    lcHtml = lcHtml + '<TR style="background:' + lxRow2Color + '" VALIGN=TOP>'
>  Else 
>    lcHtml = lcHtml + '<TR VALIGN=TOP>'
>  EndIf 
>  For x=1 to lnFields
>    Do case 
>      Case InList(type(Field(x)),'N','I','Y') 
>        lcHtml = lcHtml + '<TD ALIGN=RIGHT>' + Transform(Evaluate(Field(x))) + '</TD>'
>      Case InList(type(Field(x)),'C','M') and (Upper(Evaluate(Field(x)))='HTTP' or Upper(Evaluate(Field(x)))='FTP:')
>        lcHtml = lcHtml + '<TD><a href="' + Trim(Mline(Evaluate(Field(x)),1)) + '"> ' + Trim(Mline(Evaluate(Field(x)),1)) + '</TD>'
>      Case InList(type(Field(x)),'C','M') and ValidEmail(Alltrim(Evaluate(Field(x))))
>        lcHtml = lcHtml + '<TD><a href=mailto:' + Trim(Mline(Evaluate(Field(x)),1)) + '> ' + Trim(Mline(Evaluate(Field(x)),1)) + '</TD>'
>      Case InList(type(Field(x)),'D','M','T')
>        lcHtml = lcHtml + '<TD ALIGN=RIGHT>' + Transform(Evaluate(Field(x))) + '</TD>'
>      Case type(Field(x))='L'
>        lcHtml = lcHtml + '<TD ALIGN=RIGHT>' + Iif(Evaluate(Field(x)),'Ja','Nei') + '</TD>'
>      Otherwise 
>        lcHtml = lcHtml + '<TD>' + Trim(Evaluate(Field(x))) + '</TD>'
>    EndCase 
>  EndFor        
>  lcHtml = lcHtml + '</TR>' + crlf
>  lnRecord = lnRecord + 1 
>EndScan   
>Return lcHTML
Looks good thanks very much
Specialist in Advertising, Marketing, especially Direct Marketing

I run courses in Business Management and Marketing
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform