예제 #1
0
        private TCell GetPreCell(TSheet sheet, TCell cell)
        {
            var row = sheet.Head.Rows[cell.RowIndex];

            for (int i = 0; i < row.Cells.Count; i++)
            {
                if (cell == row.Cells[i])
                {
                    return(row.Cells[i - 1]);
                }
            }
            return(null);
        }
예제 #2
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);
        }
예제 #3
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);
     }
 }
예제 #4
0
        private int GetColumnIndex(TSheet sheet, TCell cell)
        {
            TCell preCell = GetPreCell(sheet, cell);

            return(0);
        }