Create Excel (SpeadsheetML) output with XSLT

后端 未结 1 1982
野趣味
野趣味 2021-02-06 20:14

I have this XML file and I want to create an XSL file to convert it to Excel. Each row should represent a logo. The columns will be the key attributes like color, id, descriptio

1条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 20:23

    You were very close. Try to be more specific when it comes to template matching - don't say template match"/*/*/*" when you can say template match="field".

    Other than that, this is your approach, only slightly modified:

     
      
    
      
        
          
        
      
    
        
        
          
              
              
            
          

    Your "repeating column names" problem roots in this expression:

    
    

    In your context, this selects any third level element in the document (literally all nodes in all s), and makes a header row out of them. I replaced it with

    
    

    which makes a header row out of the first only.

    If a certain column order is required (other than document order) or not all nodes are in the same order for all s, things get more complex. Tell me if you need that.

    0 讨论(0)
提交回复
热议问题