XML for spreadsheets
Moderator: Rathinagiri
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: XML for spreadsheets
I don't think so. (At least for exporting)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: XML for spreadsheets
Hi Rathi,
I said this because I found following line in the HMG\Harbour\ChangeLog file
There may be some functions which can handle xml nodes easily. But, I may be wrong, as I have very little (almost zero) knowledge about xml files.
Thanks in advance
I said this because I found following line in the HMG\Harbour\ChangeLog file
Code: Select all
...
* contrib/xhb/hbxml.c
Thanks in advance
With best regards,
Sudip
Sudip
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: XML for spreadsheets
Yes. That is there. IMHO, that would be very much useful for retrieval from xml file than exporting.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: XML for spreadsheets
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
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
With best regards,
Sudip
Sudip
Re: XML for spreadsheets
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 nil
Re: XML for spreadsheets
Very 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 )
I've seen the TALLY ACCOUNTING PACKAGE (most widely used FA package in India) having the facility of importing & exporting data in XML format. If they have choosen this medium then this can be a very "happening" medium of exchange of data between two applications.
- nguyenchiduc
- Posts: 78
- Joined: Sat Nov 13, 2010 7:27 am
Re: XML for spreadsheets
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
With any simple file structure that we know, we can use low level functions to read and write.
Sometimes for a dbf file sizes larger in PC or SQL Server, we only need to export a few fields only.
And otherwise from the XML to dbf
Depending on the purpose we will write your own functions to import/export