Re: XML for spreadsheets
Posted: Mon Jun 28, 2010 12:42 pm
I don't think so.
(At least for exporting)
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://mail.hmgforum.com/
Code: Select all
...
* contrib/xhb/hbxml.c
One of the ODBC or ADO version:sudip wrote:Hello All,
I want to export my data in XML format, so that it can be opened with any modern spreadsheet. Is there any easy way to do this? Or I shall write all the XML codes ...
Is there any utility which can export DBF to XML? Or Grid to XML
Thanks in advance
(After 15 minutes: IMHO, it is not very complex to write code for DBF2XML, I shall do it)
Code: Select all
Function Table2XML(oRecordSet, cTable, cFile)
LOCAL nFields
LOCAL nHandle
LOCAL cBuffer
LOCAL i:=1
#define CRLF Chr(13)+Chr(10)
if cFile=NIL
cFile:="tmp.xml"
end
nHandle:=fCreate( cFile, 0 )
nFields := oRecordSet:Count()-1
DO WHILE .NOT. oRecordSet:Eof()
cBuffer:=Space(2)+"<"+cTable+">"+CRLF
fWrite(nHandle,cBuffer)
FOR nField:=0 TO nFields
cBuffer:=Space(4)+"<"+oRecordSet:Fields(nField):Name+">"//Beginning Record Tag
DO CASE
CASE Valtype(oRecordSet:Fields(nField):Value) == "D"
cValue := Dtos(oRecordSet:Fields(nField):Value)
CASE Valtype(oRecordSet:Fields(nField):Value) == "N"
cValue := Str(oRecordSet:Fields(nField):Value)
CASE Valtype(oRecordSet:Fields(nField):Value) == "L"
cValue := If( oRecordSet:Fields(nField):Value, "True", "False" )
OTHERWISE
cValue := oRecordSet:Fields(nField):Value
ENDCASE
cValue:=strTran(cValue,"&","&")
cValue:=strTran(cValue,"<","<")
cValue:=strTran(cValue,">",">")
cValue:=strTran(cValue,"'","'")
cValue:=strTran(cValue,["],["])
cBuffer:=cBuffer + ;
Alltrim( cValue ) + ;
"</" + ;
oRecordSet:Fields(nField):Name + ;
">" + ;
CRLF
fWrite(nHandle,cBuffer)
NEXT nField//Ending Record Tag
fWrite(nHandle,Space(2)+"</"+cTable+">"+CRLF)
oRecordSet:MoveNext()
? ++i
ENDDO
oRecordSet:Close()
fClose(nHandle)
Return nilVery good initiative Sudip!sudip wrote:Hello All,
I want to export my data in XML format, so that it can be opened with any modern spreadsheet. Is there any easy way to do this? Or I shall write all the XML codes ...
Is there any utility which can export DBF to XML? Or Grid to XML
Thanks in advance
(After 15 minutes: IMHO, it is not very complex to write code for DBF2XML, I shall do it)
Not only for XMLsudip wrote:Yes, Rathi. You are correct![]()
Actually I am searching for a better method for both read from xml file and export to xml file.
I saw some examples in other Harbour/xHarbour libraries, but yesterday I was not able to transfer them to HMG