Results 1 to 4 of 4

Thread: Excel - Ignore empty cells/rows when using XML-Export

  1. #1

    Thread Starter
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Excel - Ignore empty cells/rows when using XML-Export

    Hiho,

    issue: User uses an Excel-Sheet filling out pertinent data for a freight-carrier order
    There is data only to be filled once (Sender, receiver etc.)
    and repeating data (Positions 1 to 20, e.g. content, packaging, dimension of packaging, gross-weight etc.)

    The user then clicks on a button (where a macro is then executed) to create an XML-File
    This is done via

    Code:
    ActiveWorkbook.XmlMaps("MyXMLMap").ExportXml data:=XML_str
    Looking at the XML-File i noticed that the Export-function also pulls the "empty" cells/rows of the positiondata (Position 2-20)

    Is there any way, to tell Excel to ignore those cells/rows?

    Or do i have to walk through the XML-File sequentially and delete any empty entries?

    Appreciate any help

    Zvoni
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Excel - Ignore empty cells/rows when using XML-Export

    How is XML_str generated?

  3. #3

    Thread Starter
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: Excel - Ignore empty cells/rows when using XML-Export

    That's the complete Function:

    Code:
    Sub GenerateXML(Directory As String, File As String)
        Dim XML_str As String
        
    
        ActiveWorkbook.XmlMaps("CarloAuftragIn").ExportXml data:=XML_str
        'Remove first line
        XML_str = Mid(XML_str, 39)
        
        Open Directory & "\" & File For Output As #1
        
        Print #1, "<?xml version=""1.0"" encoding=""ISO-8859-1"" standalone=""yes""?>"
        Print #1, "<!DOCTYPE CarloAuftragIn []>"
        'Remove Namespace
        XML_str = Replace(XML_str, "<ns2:CarloAuftragIn xmlns:ns2=""http://www.soloplan.de/XML/CarLoAuftragIn"">", "<CarloAuftragIn>")
        XML_str = Replace(XML_str, "ns2:", "")
        Print #1, XML_str
        Close #1
    End Sub
    It basically uses a XML-Map which is defined inside the Workbook
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  4. #4
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Excel - Ignore empty cells/rows when using XML-Export

    Ok, looks a little out of my element...

    I'd be happy to experiment with it (as a 2nd set of eyes with little knowledge on the topic), but don't know how to simulate what you're doing/getting. If you want to upload a sample, I'd walk through it...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width