我有一个包含 xml 脚本的工作表,它大约有 15 列 x 70000 行。我试图将此数据保存到 .xml
文件中。我目前使用的代码是:
Sub saveXML()
Dim GenerateSheet As Worksheet
Set GenerateSheet = ThisWorkbook.Sheets("TestCase-")
GenerateSheet.SaveAs Filename:="C:\Users\" & "TestCase-" + Format(Now(), "YYYYMMDD") & ".xml", FileFormat:=xlTextWindows
End Sub
这会将其另存为 .xml 文件,但似乎会在文件中的随机行周围添加引号,这会破坏 xml 文件。
"<con:testCase xmlns:con=""http://eviware.com/soapui/config"" failOnError=""true"" failTestCaseOnErrors=""false"" keepSession=""false"" maxResults=""0"" name=""name"" searchProperties=""true"">"
<con:settings/>
"<con:testStep type=""request"" name=""TestStep_0001"">"
<con:settings/>
"<con:config xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:type=""con:RequestStep"">"
<con:interface>QuoteService</con:interface>
<con:operation>NewRate</con:operation>
"<con:request name=""NewRate - Request 1"" outgoingWss="""" incomingWss="""" timeout="""" sslKeystore="""" useWsAddressing=""true"" useWsReliableMessaging=""false"" wssPasswordType="""">"
<con:settings>
在工作表中,任何行都没有引号。
我如何控制或防止这种行为?
最佳答案
引用的标签无效。 (他们错过了结束标签并且不会自动关闭)。在每个引用标记的末尾添加一个/以使其自动关闭。
示例(注意末尾的“/”)
<con:request name="NewRate - Request 1" outgoingWss="" incomingWss="" timeout="" sslKeystore="" useWsAddressing="true" useWsReliableMessaging="false" wssPasswordType=""/>
关于xml - 将 Excel 工作表另存为 xml 在某些行周围添加引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39269906/