Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert excel to DBF file
Message
 
 
To
25/07/2017 05:46:49
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01652806
Message ID:
01652828
Views:
61
>>
>>I have converted the sample .xls to the XML 2003 format. How would I import it into a DBF/cursor?
>
>This uses an XSL Transformation, to prepare the data that you receive in Excel, exported as XML (Excel 2003 Format), in a form that XMLTOCURSOR() can understand and process. I don't know if there are other data elements in the original records, but I think that this covers the sample you provided.
>
>
>LOCAL XMLSource AS String
>
>m.XMLSource = GETFILE("xml")
>
>LOCAL XMLComplexExcel AS String
>
>TEXT TO m.XMLComplexExcel NOSHOW
><?xml version="1.0" encoding="UTF-8"?>
><xsl:stylesheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  version="1.0">
>  
>  <xsl:output method="xml" indent="yes" cdata-section-elements="Instructions"/>
>  
>  <xsl:template match="/">
>    <xsl:element name="VFPData">
>      <xsl:call-template name="record">
>        <xsl:with-param name="table" select="/ss:Workbook/ss:Worksheet[@ss:Name='Sheet1']/ss:Table"/>
>      </xsl:call-template>
>    </xsl:element>
>  </xsl:template>
>  
>  <xsl:template name="record">
>    <xsl:param name="base" select="4"/>
>    <xsl:param name="table"/>
>
>    <xsl:variable name="procId" select="$table/ss:Row[$base]/ss:Cell[2]/ss:Data"/>
>    <xsl:if test="$procId">
>      <xsl:element name="Procedure">
>        <xsl:element name="procedureId">
>          <xsl:value-of select="$procId"/>
>        </xsl:element>
>        <xsl:element name="procedureName">
>          <xsl:value-of select="$table/ss:Row[$base]/ss:Cell[3]/ss:Data"/>
>        </xsl:element>
>        <xsl:element name="EstHrs">
>          <xsl:value-of select="$table/ss:Row[$base + 1]/ss:Cell[2]/ss:Data"/>
>        </xsl:element>
>        <xsl:element name="Type">
>          <xsl:value-of select="$table/ss:Row[$base + 1]/ss:Cell[4]/ss:Data"/>
>        </xsl:element>
>        <xsl:element name="Skill">
>          <xsl:value-of select="$table/ss:Row[$base + 2]/ss:Cell[2]/ss:Data"/>
>        </xsl:element>
>        <xsl:element name="Shutdown">
>          <xsl:value-of select="$table/ss:Row[$base + 2]/ss:Cell[4]/ss:Data"/>
>        </xsl:element>
>        <xsl:element name="Reading">
>          <xsl:value-of select="$table/ss:Row[$base + 3]/ss:Cell[2]/ss:Data"/>
>        </xsl:element>
>        <xsl:element name="Instructions">
>          <xsl:value-of select="$table/ss:Row[$base + 5]/ss:Cell[1]/ss:Data"/>
>        </xsl:element>
>      </xsl:element>
>      <xsl:call-template name="record">
>        <xsl:with-param name="table" select="$table"/>
>        <xsl:with-param name="base" select="$base + 10"/>
>      </xsl:call-template>
>    </xsl:if>
>  </xsl:template>
></xsl:stylesheet>
>ENDTEXT
>
>LOCAL XMLDom AS MSXML2.DOMDocument60
>LOCAL XSLT AS MSXML2.DOMDocument60
>
>m.XMLDom = CREATEOBJECT("MSXML2.DOMDocument.6.0")
>m.XMLDom.async = .F.
>m.XMLDom.load(m.XMLSource)
>
>m.XSLT = CREATEOBJECT("MSXML2.DOMDocument.6.0")
>m.XSLT.async = .F.
>m.XSLT.loadXML(m.XMLComplexExcel)
>
>XMLTOCURSOR(m.XMLDom.transformNode(m.XSLT), "testCursor")
>
>SELECT testCursor
>BROWSE
>
Thank you very much.
The line at the top
m.XMLSource = GETFILE("xml")
should I replace the "xml" with "myxmlfile.xml"? Because when I do, somehow, I get an error "No file match your search".
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform