Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would probably do it with Linq for XML methods rather than string manipulation, but the choice is yours. </p> <p>Either way, it shouldn't be that hard to write a method that takes a grid output (I am assuming it's a string), extracts the contents, and returns them. The calling routine then assembles the 14 XML strings and wraps them in a single Worksheet tag. </p> <p>Here's a stab at it. Bear in mind that I'm not familiar with the RadGridView and the output of ToExcelML, so you probably won't be able to use this code without some modification. I'm making some assumptions that may not be valid.</p> <p>First, I would create a method that takes an XML string as input. I am assuming that this string is entirely wrapped in a &lt;Worksheet<i>n</i>&gt; tag.</p> <pre><code>string ExtractWorksheetContents(string excelML, int index) { // You might also be able to do this with a regex, depending on how the contents are structured // Since I don't know enough about the content, I will do this with string manipulation, as // you did, rather than loading the XML and making assumptions. string tagName = string.Format("Worksheet{0}", index); int worksheetStart = excelML.IndexOf("&lt;" + tagName); int worksheetEnd = excelML.IndexOf("&lt;/" + tagName + "&gt;") + tagName.Length + 3); // Should contain some checks that neither w'sheet start nor end are -1 return excelML.Substring(worksheetStart, worksheetEnd-worksheetStart); } </code></pre> <p>Then I would assemble the results. Again, I'm making assumptions about how the XML is structured.</p> <pre><code>StringBuilder sb = new StringBuilder(); sb.Append("&lt;Worksheet&gt;"); RadGridView[] gridViews = new RadGridView[] { RadGridView1, RadGridView2 .... RadGridView14 }; for(int i=0;i&lt;14; i++) { var rgv = gridViews[i]; sb.Append(ExtractWorksheetContents(rgv.ToExcelML(),i+1)); } sb.Append("&lt;/Worksheet&gt;"); var workBook = sb.ToString(); </code></pre> <p>Hope this helps somewhat. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload