[英]Map multiple excel cells into xml
我將盡力解釋我的問題(對不起,我的英語)。
我有一個以這種方式構造的Excel文件。
第1列第2列第3列...第N列Mario Luigi 2桃子Wario。 。 。
我有一個XML模式(.xds)來映射該電子表格。 該架構為:
<root id="x">
<Column1> *something*</Column1>
<Column2> *something*</Column2>
*...and so on...*
</root>
當我將Excel文件映射為XML Schema時,我只能將一個單元格轉換為一個xml元素。 因此,我可以將帶有元素Column1的Column1單元格映射到XML模式。 我希望這很清楚。 但是我想為XML模式中的元素Column1映射多個單元。 換句話說,當我從Excel導出XML文件時(每行一個),我想獲取多個。
我應該映射多個單元格
<root id="1">
<Column1> 1</Column1>
<Column2> Mario</Column2>
*...and so on...*
</root>
<root id="2">
<Column1> 1</Column1>
<Column2> Peach</Column2>
*...and so on...*
</root>
我只映射一個單元格
<root id="1">
<Column1> 1</Column1>
<Column2> Mario</Column2>
*...and so on...*
</root>
我希望我的問題很清楚:如何為XML方案的一個元素映射多個單元?
謝謝。
嘗試將XLS文件轉換為CSV文件,然后使用python腳本將CSV文件轉換為XML文件。 檢查此代碼CSV到XML
或者,您可以簡單地使用xml代碼編寫一個文本文件,然后以所需的擴展名保存它。 例如
Dim fsT As Object
Set fsT = CreateObject("ADODB.Stream")
fsT.Type = 2 ' Specifies stream type - save text data.
fsT.Charset = "utf-8" ' Specifies charset For the source text data.
fsT.lineseparator = 10 ' Pushes enter when a line is finished
fsT.Open
fsT.WriteText <root id="1">, 1
fsT.WriteText <Column1> 1</Column1>, 1 ' you can substitute a Cell.Column to this "1"
fsT.WriteText <Column2> Mario</Column2>, 1 ' same here, you can give input by a cell for example
fsT.WriteText *...and so on...* , 1
fsT.WriteText </root>, 1
' Do it how many times you want then...
fsT.SaveToFile YourFileName, 2 ' Saves (and overwrites) data
fsT.Close
Set fsT = Nothing
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.