独自のVBAマクロを構築することができます。このように。 Microsoft.xmlへの参照を追加します。
Sub makeXml()
ActiveCell.SpecialCells(xlLastCell).Select
Dim lastRow, lastCol As Long
lastRow = ActiveCell.Row
lastCol = ActiveCell.Column
Dim iRow, iCol As Long
Dim xDoc As New DOMDocument
Dim rootNode As IXMLDOMNode
Set rootNode = xDoc.createElement("Root")
Dim rowNode As IXMLDOMNode
Dim colNode As IXMLDOMNode
'loop over the rows
For iRow = 2 To lastRow
Set rowNode = xDoc.createElement("Row")
'loop over the columns
For iCol = 1 To lastCol
If (Len(ActiveSheet.Cells(1, iCol).Text) > 0) Then
Set colNode = xDoc.createElement(GetXmlSafeColumnName(ActiveSheet.Cells(1, iCol).Text))
colNode.Text = ActiveSheet.Cells(iRow, iCol).Text
rowNode.appendChild colNode
End If
Next iCol
rootNode.appendChild rowNode
Next iRow
xDoc.appendChild rootNode
fileSaveName = Application.GetSaveAsFilename(_
fileFilter:="XML Files (*.xml), *.xml")
xDoc.Save (fileSaveName)
set xDoc = Nothing
End Sub
Function GetXmlSafeColumnName(name As String)
Dim ret As String
ret = name
ret = Replace(ret, " ", "_")
ret = Replace(ret, ".", "")
ret = Replace(ret, ",", "")
ret = Replace(ret, "&", "")
ret = Replace(ret, "!", "")
ret = Replace(ret, "@", "")
ret = Replace(ret, "$", "")
ret = Replace(ret, "#", "")
ret = Replace(ret, "%", "")
ret = Replace(ret, "^", "")
ret = Replace(ret, "*", "")
ret = Replace(ret, "(", "")
ret = Replace(ret, ")", "")
ret = Replace(ret, "-", "")
ret = Replace(ret, "+", "")
GetXmlSafeColumnName = ret
End Function
Excel 2007 **は** XMLスプレッドシートです。 – RBarryYoung