Tag: xml

在Excel中从string列表中分割列

我正在尝试创build基于文本文件的Excel文档。 这是我的文本文件的一个例子: example.txt文件 |<Number1>| |TREE= 800 | |BIRD = 500 | |FISH = 25 | |DOG = 10 | |CAT = 5 | |ANOTHERCAT = 800 | |THERESOMANYCATS = 3 | |HAMSTER = 5 | |<Number2>| |TREE= 800 | |BIRD = 500 | |FISH = 25 | |DOG = 10 | |CAT = 5 | […]

如何在Excelmacros或VB.Net中将JSON数据转换为xml数据

我正在获取JSON格式的数据 { “名称”: “瑞恩”, “年龄”:1, “滚动”:2 “地址”: “AAA”},{ “名称”: “瑞恩”, “年龄”:1, “滚”:2 , “地址”: “AAA”},{ “名称”: “瑞恩”, “年龄”:1, “滚动”:2 “地址”: “AAA”},{ “名称”: “瑞恩”,”年龄 “:1,” 滚动 “:2”,地址 “:” AAA“}] 它如何被转换成XML格式。 所以我可以用它填充我的Excel电子表格。 或者有没有什么办法可以直接将JSON数据转换为Excel中的macros

parsing复杂的XML文件

我在parsing从Excel中的API中检索到的XML文件时遇到问题。 我可以成功检索数据集(下面),但是我发现将每个字段格式化为自己的单元格为表格格式的解决scheme没有奏效,我想是因为XML格式化的方式。 每个XML将如下所示。 可能有多个消息ID需要独立提取。 (这是我遇到的另一个问题,“消息ID”中的空间引发了各种各样的错误。) 以下是我正在尝试使用的解决scheme: 如何使用vbaparsingXML <?xml version="1.0" encoding="utf-8"?> <methodResponse><item><methodName><![CDATA[legacy.message_stats]]> </methodName><responseData><message_data> <message id="9999"> <message_subject><![CDATA[50% rabatt på alla kort! Skicka ett personligt julkort i år!]]></message_subject> <date_sent>2015-09-13 19:15:48</date_sent> <message_notes><![CDATA[50% Off Holiday Cards, SE]]></message_notes> <withheld_total> 0</withheld_total> <globally_suppressed> 0</globally_suppressed> <suppressed_total> 0</suppressed_total> <bill_codes><![CDATA[emc_0914_HOLIDAYCARDS_SE]]></bill_codes> <sent_total> 15195</sent_total> <sent_total_html> 15195</sent_total_html> <sent_total_plain> 0</sent_total_plain> <sent_rate_total>100.00</sent_rate_total> <sent_rate_html>100.00</sent_rate_html> <sent_rate_plain>0.00</sent_rate_plain> <delivered_total> 15060</delivered_total> <delivered_html> 15060</delivered_html> <delivered_plain> 0</delivered_plain> <delivered_rate_total>99.11</delivered_rate_total> […]

openpyxl不可读的内容

当使用openpyxl,如果我更新像这样的单元格样式: wb = Workbook() ws = wb.active a1 = ws['a1'] al.value = 'Hello World!' a1.style.font.name = 'Algerian' 在Excel中打开文件给出了一个错误: “Excel发现不可读的内容…” 日志文件: <?xml version="1.0" encoding="UTF-8" standalone="true"?> -<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <logFileName>error107840_01.xml</logFileName> <summary>Errors were detected in file 'D:\Phocas\Phocas-Automation\test.xlsx'</summary> -<removedRecords summary="Following is a list of removed records:"> <removedRecord>Removed Records: Cell information from /xl/worksheets/sheet1.xml part</removedRecord> </removedRecords> </recoveryLog> 单元格显示正确的样式(font.name = Algerian),但在将文件分发给用户时,错误消息是不可取的。 这也只是一个例子,我得到同样的问题,如果我尝试像这样: a1.style.font.bold […]

使用XSLT从Excel中检索数据

我有一个excel如下,其中第5行的标题数据。 编辑: inputexcel也可能出现如下。 数据可能出现在任何列中。 数据必须使用行标题广告名称,UID和Status.It不会更改。 然后将其保存为工作簿xml,如下所示 <?xml version="1.0"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"> <Author>Jefferson D</Author> <LastAuthor>Jefferson D</LastAuthor> <Created>2015-10-29T17:10:31Z</Created> <LastSaved>2015-10-29T17:15:02Z</LastSaved> <Company>*CL</Company> <Version>12.0</Version> </DocumentProperties> <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> <AllowPNG/> </OfficeDocumentSettings> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> <WindowHeight>22060</WindowHeight> <WindowWidth>34400</WindowWidth> <WindowTopX>-20</WindowTopX> <WindowTopY>-20</WindowTopY> <Date1904/> <ProtectStructure>False</ProtectStructure> <ProtectWindows>False</ProtectWindows> </ExcelWorkbook> <Styles> <Style ss:ID="Default" ss:Name="Normal"> <Alignment ss:Vertical="Bottom"/> <Borders/> <Font ss:FontName="Verdana"/> <Interior/> <NumberFormat/> <Protection/> </Style> <Style ss:ID="s16"> <Font […]

以三种不同的方式将XML文件导入Excel

我的XML文件看起来像这样: 当我将这个文件导入Excel时,我得到一个包含其内容的表格。 但是,我需要为每个标签分别使用三个表格: <Header> <MasterFiles> <SourceDocuments> 因为它们看起来像三个相关的表格。 我用来导入文件的代码是: strTargetFile = "C:\SAFT.xml" Set wb = Workbooks.OpenXML(Filename:=strTargetFile, LoadOption:=xlXmlLoadImportToList) wb.Sheets(1).UsedRange.Copy ThisWorkbook.Sheets("Sheet2").Range("A1") 但是如何将XML文件分解成三部分并将每个文件导入到不同的工作表?

加载一个带有variables文件名的XML文件,用XSL进行转换

我正在寻找在Excel VBA中运行以下: Dim xmldoc As Object, xsldoc As Object, newdoc As Object Set xmldoc = CreateObject("MSXML2.DOMDocument") Set xsldoc = CreateObject("MSXML2.DOMDocument") Set newdoc = CreateObject("MSXML2.DOMDocument") ' LOAD XML xmldoc.async = False xmldoc.Load ActiveWorkbook.Path & "\Original.xml" ' LOAD XSL xsldoc.async = False xsldoc.Load ActiveWorkbook.Path & "\XSLT_File.xsl" ' TRANSFORM xmldoc.transformNodeToObject xsldoc, newdoc newdoc.Save ActiveWorkbook.Path & "\Output.xml" 我在相同的代码中运行这个,但之后,步骤,而原始的XML被导出 ActiveWorkbook.SaveAsXMLData […]

parsing不同数量的标签的XML,以使长度相等的列表。 openpyxl和Beautifulsoup

我有一个XML文件,其中有包含作者,出版date,标签等标签的书籍logging。 我将parsing这个文件来创build3个列表,其中一个将有书名,另一个列表中的作者,最后是第三个列表中的标签,稍后我将使用openpyxl将这些列表写入Excel列。 问题是一些书籍logging没有标签标签。 使用普通的美味汤的parsing技术将产生相同长度的前两个列表,但标签列表将具有较短的长度。 我有三个问题: 1-如何创build所有三个长度相同的列表(没有标签标签的书籍为空)2-标签列表看起来像这样['Energy; Green Buildings; High Performance Buildings','Computing','Computing ;devise;绿色build筑“,…….]我已经创build了另外15个标题,标题名称是我的,例如”计算“和”devise“,有没有什么办法可以使用openpyXL为图书标签组合创build一个X标记或彩色单元格,例如,如果一本书中包含特定的标签,例如,如果第5行中的标题为“Architecture”的书具有“Design”标签,则需要单元格中的X标记或有色单元格(row'5',col'Design')。是否有更简单的方法来完成此任务(parsingXML文件并在Excel中高效编写)? 下面是XML文件的快照和我写的代码(也可以从这里下载XML文件和Python文件: http : //www.ranialabib.com/#! python/ icfwa <?xml version="1.0" encoding="UTF-8"?> <xml> <records> <record> <database name="My Collection.enl" path="My Collection.enl">My Collection.enl</database> <ref-type name="Book">1</ref-type> <contributors> <authors> <author>AIA Research Corporation</author> </authors> </contributors> <titles> <title>Regional guidelines for building passive energy conserving homes</title> </titles> <periodical/> <keywords/> <dates> <year>1978</year> </dates> <publisher>Dept. […]

使用谷歌电子表格function内的单元格引用

我正在使用Google电子表格function。 这个公式工作正常。 =ImportXML("https://www.google.com/finance?q=SHA:000001", "//span[@class='pr']") stringSHA:000001包含在单元格B4 。 我想使用单元格引用。 所以,我改成公式来 =ImportXML("https://www.google.com/finance?q=" + B4, "//span[@class='pr']") 不幸的是,这并没有奏效。 返回的值是#VALUE! 。 如何正确的公式看起来像?

格式化和组织电子表格结果

我正在尝试使用以下代码创buildExcel文件 XML: <?xml version="1.0" encoding="utf-8"?> <Document> <Header> <NoInvoices>3</NoInvoices> <ExportDate>11-20-2015</ExportDate> </Header> <Invoices> <Type>CN</Type> <Customer>Juan</Customer> <CustAddress>New Bilibid</CustAddress> <InvNumber>01234</InvNumber> <Items> <Name>Sugar</Name> <Qty>2</Qty> <Price>5</Price> <Amount>10</Amount> <OrigInv>01235</OrigInv> </Items> </Invoices> <Invoices> <Type>SI</Type> <Customer>Juan</Customer> <CustAddress>New Bilibid</CustAddress> <InvNumber>01235</InvNumber> <Items> <Name>Coffee</Name> <Qty>5</Qty> <Price>25</Price> <Amount>125</Amount> </Items> <Items> <Name>Sugar</Name> <Qty>5</Qty> <Price>5</Price> <Amount>25</Amount> </Items> </Invoices> <Invoices> <Type>SI</Type> <Customer>Julianna</Customer> <CustAddress>New Wares</CustAddress> <InvNumber>01236</InvNumber> <Items> <Name>Margarine</Name> <Qty>1</Qty> <Price>50</Price> <Amount>50</Amount> </Items> […]