示例#1
0
        private TSheet CreateSheet(XmlNode tableNode)
        {
            TSheet sheet = new TSheet();

            sheet.Head = new THead();
            if (tableNode.Attributes["name"] != null)
            {
                sheet.Name = tableNode.Attributes["name"].Value;
            }
            XmlNodeList nodeList = tableNode.SelectNodes("thead/tr");

            for (int i = 0; i < nodeList.Count; i++)
            {
                XmlNode tr  = nodeList[i];
                TRow    row = new TRow();
                for (int j = 0; j < tr.ChildNodes.Count; j++)
                {
                    XmlNode th   = tr.ChildNodes[j];
                    TCell   cell = new TCell();
                    cell.RowIndex = i;
                    cell.Name     = th.Attributes["field"] == null ? string.Empty : th.Attributes["field"].Value;
                    cell.Caption  = th.InnerText;
                    if (th.Attributes["colspan"] != null)
                    {
                        cell.ColSpan = int.Parse(th.Attributes["colspan"].Value);
                    }
                    if (th.Attributes["rowspan"] != null)
                    {
                        cell.RowSpan = int.Parse(th.Attributes["rowspan"].Value);
                    }
                    cell.ColumnIndex = j;
                    row.Cells.Add(cell);
                }
                sheet.Head.Rows.Add(row);
            }
            CalculateCells(sheet);
            return(sheet);
        }
示例#2
0
 public void Load(DataSet ds)
 {
     foreach (DataTable dt in ds.Tables)
     {
         TSheet sheet = new TSheet();
         sheet.Title = dt.TableName;
         sheet.Name  = sheet.Title;
         sheet.Head  = new THead();
         TRow row = new TRow();
         sheet.Head.Rows.Add(row);
         int i = 0;
         foreach (DataColumn column in dt.Columns)
         {
             TCell cell = new TCell();
             cell.RowIndex    = 0;
             cell.ColumnIndex = i;
             cell.Name        = column.ColumnName;
             cell.Caption     = string.IsNullOrEmpty(column.Caption)?column.ColumnName:column.Caption;
             row.Cells.Add(cell);
             i++;
         }
         this.template.Sheets.Add(sheet);
     }
 }