I am new to the programming world, so this question may be silly, but I was stuck and was hoping to get some help.
I use XDocument to modify and add information to an Excel worksheet (which is an XML document) in a project to get an Excel report from Autodesk Revit. A worksheet document consists of worksheet information, including rows and cells in this configuration:
<row r="11" spans="1:11" x14ac:dyDescent="0.2"> <cr="A11" s="198" t="inlineStr"> <is> <t>example</t> </is> </c> <cr="B11" s="199" t="inlineStr"> <is> <t>string</t> </is> </c> <cr="C11" s="200"/> <cr="D11" s="201"/> <cr="E11" s="201"/> <cr="F11" s="202"/> <cr="G11" s="203"/> <cr="H11" s="204"/> <cr="I11" s="205"/> <cr="J11" s="205"/> <cr="K11" s="206"/> </row>
The corresponding piece of code is in the row element. The spans attribute attribute has a value of "1:11", and where my problem is. This will not allow me to enter the character ':' as an attribute value. I searched the network and found that it had something to do with the namespace declaration at this link: "Character ':', hexadecimal value 0x3A, cannot be included in the name"
However, getting this ':' character into an attribute value is required for the Excel document to work. I create a line item as follows:
XElement row = new XElement("row", new XAttribute("r", i.ToString()), new XAttribute("spans", "1:" + collumnCount.ToString()), new XAttribute("x14ac:dyDescent", "0.2"));
I do not understand why this does not allow me to put ':' in the value of XAttribute, since this is just a string. Is there any way to make this work?
I tried adding the string β1:11β to the XMLAttribute using XMLDocument. It really works, but I can't believe it is not possible with XDocument.
Thank you in advance
source share