XML for spreadsheets

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
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

Post by Rathinagiri »

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.
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: XML for spreadsheets

Post by sudip »

Hi Rathi,

I said this because I found following line in the HMG\Harbour\ChangeLog file

Code: Select all

 ...

  * contrib/xhb/hbxml.c
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 :)
With best regards,
Sudip
User avatar
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

Post by Rathinagiri »

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.
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: XML for spreadsheets

Post by sudip »

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 best regards,
Sudip
Kana
Posts: 27
Joined: Sun Feb 07, 2010 2:48 pm

Re: XML for spreadsheets

Post by Kana »

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 :) )
One of the ODBC or ADO version:

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,"'","&apos;")
       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
User avatar
swapan
Posts: 242
Joined: Mon Mar 16, 2009 4:23 am
Location: Kolkata, India
Contact:

Re: XML for spreadsheets

Post by swapan »

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 :) )
Very good initiative Sudip!

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.
Thanks & Regards,
Swapan Das

http://www.swapandas.com/
User avatar
nguyenchiduc
Posts: 78
Joined: Sat Nov 13, 2010 7:27 am

Re: XML for spreadsheets

Post by nguyenchiduc »

sudip 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 ;)
Not only for XML
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
Post Reply