Exemplo n.º 1
0
        protected virtual List <int> ParseXmlPattern()
        {
            var lastRowIndexes = new List <int>();

            foreach (var worksheet in Xdoc.Element("document").Element("worksheets").Elements("worksheet"))
            {
                var worksheetName = worksheet.Attribute("name")?.Value;
                var wsheet        = Excel.Workbook.Worksheets.Add(worksheetName);

                var rowIndex = 1;
                foreach (var row in worksheet.Element("rows").Elements("row"))
                {
                    var columnIndex = 1;
                    foreach (var header in row.Element("headers").Elements("header"))
                    {
                        var span = header.Attribute("span") == null ? 1 : int.Parse(header.Attribute("span").Value);
                        wsheet.Cells[rowIndex, columnIndex, rowIndex, columnIndex + (span - 1)].Merge = true;
                        wsheet.Cells[rowIndex, columnIndex].Value = header.Value;
                        columnIndex += span;
                    }
                    rowIndex += 1;
                }
                lastRowIndexes.Add(rowIndex);
            }
            return(lastRowIndexes);
        }
Exemplo n.º 2
0
 public IEnumerable <YahooStat> LoadStats(
     string playerId, string season, string week)
 {
     return(Xdoc.Element("stat-list")
            .Elements("stat")
            .Where(e => e.Attribute("id").Value == playerId &&
                   e.Attribute("season").Value == season &&
                   e.Attribute("week").Value == week)
            .Select(r => new YahooStat
     {
         Id = ( string )r.Attribute("id"),
         Season = ( string )r.Attribute("season"),
         Week = ( string )r.Attribute("week"),
         Qty = ( decimal )r.Attribute("qty")
     }
                    ));
 }
Exemplo n.º 3
0
        private void button4_Click(object sender, EventArgs e)
        {
            ServiceReference3.WebService1SoapClient soap = new ServiceReference3.WebService1SoapClient();
            //string xml = dataSet.GetXml();

            try
            {
                XDocument Xdoc = new XDocument(new XElement("Users"));
                if (System.IO.File.Exists("D:\\LessonManagerApp.xml"))
                {
                    Xdoc = XDocument.Load("D:\\LessonManagerApp.xml");
                }
                else
                {
                    Xdoc = new XDocument();
                    XElement xmlstart = new XElement("Users");
                    Xdoc.Add(xmlstart);
                }
                XElement xml1 = /*new XElement("Users",*/
                                new XElement("User",
                                             new XElement("StartTime", textBox1.Text),
                                             new XElement("Duration", customControl11.Text),
                                             new XElement("Notes", textBox3.Text),
                                             new XElement("Instructor_ID", comboBox1.Text));

                if (Xdoc.Descendants().Count() > 0)
                {
                    Xdoc.Descendants().First().Add(xml1);
                }
                else
                {
                    Xdoc.Add(xml1);
                }

                Xdoc.Element("Users").Save("D:\\LessonManagerApp.xml");
                soap.UploadNotes("xml1");
                MessageBox.Show("Uploaded Successfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
 public XElement Element(XName xname)
 {
     return(Xdoc.Element(xname));
 }