Inheritance: TBase
Ejemplo n.º 1
0
 public PathNode(int x, int y, TCell cellObject)
 {
     X          = x;
     Y          = y;
     CellObject = cellObject;
     G          = int.MaxValue;
 }
Ejemplo n.º 2
0
        public void GetHBaseImage(string rowKey = "20150822180801118")
        {
            var socket = new TSocket(hbaseThrif, hbaseThrifPort);
            var transport = new TBufferedTransport(socket);
            var protocol = new TBinaryProtocol(transport);
            Hbase.Client hbaseClient = new Hbase.Client(protocol);
            transport.Open();

            //List<byte[]> tableNames = hc.getTableNames();

            byte[] table = Encoding.UTF8.GetBytes("FiservImages");
            byte[] row = Encoding.UTF8.GetBytes(rowKey);
            byte[] column = Encoding.UTF8.GetBytes("ImageData:Image");

            List<TRowResult> results = hbaseClient.getRow(table, row, null);
            TCell t = new TCell();
            //t.

            foreach (TRowResult result in results)
            {
                //result.Columns[column]
                //result.Columns;
                Dictionary<byte[], TCell> konj;
                konj = result.Columns;

                //string s = Encoding.UTF8.GetString(result.Columns[column].Value);

                foreach (KeyValuePair<byte[], TCell> singleRow in konj)
                {
                    //File.WriteAllBytes(@"c:\test\output.docx", singleRow.Value.Value);
                    OpenFile(singleRow.Value.Value, "output.docx");
                }
            }
        }
Ejemplo n.º 3
0
            private MapSection Visit(TCell cell)
            {
                Stack <TCell> stack      = new Stack <TCell>(new List <TCell>());
                MapSection    mapSection = new MapSection();

                stack.Push(cell);
                while (stack.Count != 0)
                {
                    cell = stack.Pop();
                    if (_visited[cell.Y][cell.X] || !cell.IsWalkable)
                    {
                        continue;
                    }
                    mapSection.AddCell(cell);
                    _visited[cell.Y][cell.X] = true;
                    foreach (TCell neighbor in GetNeighbors(cell))
                    {
                        if (cell.IsWalkable == neighbor.IsWalkable && !_visited[neighbor.Y][neighbor.X])
                        {
                            stack.Push(neighbor);
                        }
                    }
                }
                return(mapSection);
            }
Ejemplo n.º 4
0
            public int GetHashCode(TEdge obj)
            {
                TCell source   = obj.Source;
                int   hashCode = source.GetHashCode();
                TCell target   = obj.Target;

                return(hashCode ^ target.GetHashCode());
            }
Ejemplo n.º 5
0
 public void Set(TCell tCell, string key)
 {
     if (_tCell != tCell)
     {
         SolveLog.Instance.LogPA(key, _tCell, tCell, _x, _y);
         _tCell = tCell;
     }
 }
Ejemplo n.º 6
0
    public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
    {
        iprot.IncrementRecursionDepth();
        try
        {
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);

            while (true)
            {
                field = await iprot.ReadFieldBeginAsync(cancellationToken);

                if (field.Type == TType.Stop)
                {
                    break;
                }

                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.String)
                    {
                        ColumnName = await iprot.ReadBinaryAsync(cancellationToken);
                    }
                    else
                    {
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                    }
                    break;

                case 2:
                    if (field.Type == TType.Struct)
                    {
                        Cell = new TCell();
                        await Cell.ReadAsync(iprot, cancellationToken);
                    }
                    else
                    {
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                    }
                    break;

                default:
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);

                    break;
                }

                await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
        }
        finally
        {
            iprot.DecrementRecursionDepth();
        }
    }
Ejemplo n.º 7
0
    public void Read(TProtocol iprot)
    {
        TField field;

        iprot.ReadStructBegin();
        while (true)
        {
            field = iprot.ReadFieldBegin();
            if (field.Type == TType.Stop)
            {
                break;
            }
            switch (field.ID)
            {
            case 1:
                if (field.Type == TType.String)
                {
                    Row = iprot.ReadBinary();
                }
                else
                {
                    TProtocolUtil.Skip(iprot, field.Type);
                }
                break;

            case 2:
                if (field.Type == TType.Map)
                {
                    {
                        Columns = new Dictionary <byte[], TCell>();
                        TMap _map4 = iprot.ReadMapBegin();
                        for (int _i5 = 0; _i5 < _map4.Count; ++_i5)
                        {
                            byte[] _key6;
                            TCell  _val7;
                            _key6 = iprot.ReadBinary();
                            _val7 = new TCell();
                            _val7.Read(iprot);
                            Columns[_key6] = _val7;
                        }
                        iprot.ReadMapEnd();
                    }
                }
                else
                {
                    TProtocolUtil.Skip(iprot, field.Type);
                }
                break;

            default:
                TProtocolUtil.Skip(iprot, field.Type);
                break;
            }
            iprot.ReadFieldEnd();
        }
        iprot.ReadStructEnd();
    }
Ejemplo n.º 8
0
        public void SetCell(int x, int y, TCell type, string key)
        {
            var current = playArea[x, y];

            if (current.Value != type)
            {
                playArea[x, y].Set(type, key);
            }
        }
Ejemplo n.º 9
0
    public void Read(TProtocol iprot)
    {
        iprot.IncrementRecursionDepth();
        try
        {
            TField field;
            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }
                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.String)
                    {
                        ColumnName = iprot.ReadBinary();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.Struct)
                    {
                        Cell = new TCell();
                        Cell.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                default:
                    TProtocolUtil.Skip(iprot, field.Type);
                    break;
                }
                iprot.ReadFieldEnd();
            }
            iprot.ReadStructEnd();
        }
        finally
        {
            iprot.DecrementRecursionDepth();
        }
    }
Ejemplo n.º 10
0
        internal void LogPA(string key, TCell @old, TCell @new, int x, int y)
        {
            var logItem = new LogItem {
                key = key, old = @old, @new = @new, x = x, y = y
            };

            logItem.report = $"PA:{key} Cell:{@old} -> {@new}";
            log.Add(logItem);

            WriteToLog(logItem.report);

            changes++;
        }
Ejemplo n.º 11
0
        public TGridGame(int rows, int cols)  // se unod dei due parametri vale zero, devo fare eseguire un eccezione
        {
            _nRow  = rows;
            _nCol  = cols;
            _Cells = new TCell[_nRow, _nCol];

            for (int r = 0; r < _nRow; r++)
            {
                for (int c = 0; c < _nCol; c++)
                {
                    _Cells[r, c] = new TCell();
                }
            }
        }
Ejemplo n.º 12
0
        public TGridGame()
        {
            _nRow  = _DefaultRow;
            _nCol  = _DefaultCol;
            _Cells = new TCell[_nRow, _nCol];

            for (int r = 0; r < _nRow; r++)
            {
                for (int c = 0; c < _nCol; c++)
                {
                    _Cells[r, c] = new TCell();
                }
            }
        }
Ejemplo n.º 13
0
        public void WriteXlsxTest()
        {
            string    file  = AppDomain.CurrentDomain.BaseDirectory + "/ExcelTests/t2.xlsx";
            IExcel    excel = ExcelFactory.CreateDefault();
            DataTable dt    = excel.Read(file, 0, 2);

            DataSet ds = new DataSet();

            ds.Tables.Add(dt);

            TTemplate template = new TTemplate();
            TRow      R1       = new TRow();
            TCell     A        = new TCell("A", "A", 0, 0); A.ColSpan = 2;
            TCell     B        = new TCell("", "B", 0, 2);
            TCell     C        = new TCell("C", "C", 0, 3); C.RowSpan = 2;
            TCell     D        = new TCell("D", "D", 0, 4); D.RowSpan = 2;
            TCell     E        = new TCell("", "E", 0, 5); E.ColSpan = 2;

            R1.Cells.Add(A);
            R1.Cells.Add(B);
            R1.Cells.Add(C);
            R1.Cells.Add(D);
            R1.Cells.Add(E);

            TRow  R2 = new TRow();
            TCell A1 = new TCell("A1", "A1", 1, 0);
            TCell A2 = new TCell("A2", "A2", 1, 1);
            TCell B1 = new TCell("B1", "B1", 1, 2);
            TCell E1 = new TCell("E1", "E1", 1, 5);
            TCell E2 = new TCell("E2", "E2", 1, 6);

            R2.Cells.Add(A1);
            R2.Cells.Add(A2);
            R2.Cells.Add(B1);
            R2.Cells.Add(E1);
            R2.Cells.Add(E2);
            TSheet tsheet = new TSheet();

            tsheet.Name  = "Sheet1";
            tsheet.Title = "表格O";
            tsheet.Head.Rows.Add(R1);
            tsheet.Head.Rows.Add(R2);
            template.Sheets.Add(tsheet);

            string outputFilePath = AppDomain.CurrentDomain.BaseDirectory + "/ExcelTests/out2.xlsx";
            bool   result         = excel.WriteFile(outputFilePath, ds, template);

            Assert.IsTrue(result);
        }
Ejemplo n.º 14
0
            private IEnumerable <TCell> GetNeighbors(TCell cell)
            {
                List <TCell> neighbors = new List <TCell>(8);

                foreach (int[] offset in _offsets)
                {
                    TCell neighbor = GetCell(cell.X + offset[0], cell.Y + offset[1]);
                    if (neighbor == null)
                    {
                        continue;
                    }
                    neighbors.Add(neighbor);
                }

                return(neighbors);
            }
Ejemplo n.º 15
0
 private void UpdateBounds(TCell cell)
 {
     if (cell.X > _right)
     {
         _right = cell.X;
     }
     if (cell.X < _left)
     {
         _left = cell.X;
     }
     if (cell.Y > _bottom)
     {
         _bottom = cell.Y;
     }
     if (cell.Y < _top)
     {
         _top = cell.Y;
     }
 }
Ejemplo n.º 16
0
        public Dictionary <byte[], TCell> GetHBaseImage()
        {
            var socket    = new TSocket(_hbaseThrif, _hbaseThrifPort);
            var transport = new TBufferedTransport(socket);
            var protocol  = new TBinaryProtocol(transport);

            Hbase.Client hbaseClient = new Hbase.Client(protocol);
            Dictionary <byte[], TCell> hbaseResult = new Dictionary <byte[], TCell>();

            transport.Open();

            //List<byte[]> tableNames = hc.getTableNames();

            byte[] table  = Encoding.UTF8.GetBytes("FiservImages");
            byte[] row    = Encoding.UTF8.GetBytes(_documentId);
            byte[] column = Encoding.UTF8.GetBytes("ImageData:Image");

            List <TRowResult> results = hbaseClient.getRow(table, row, null);
            TCell             t       = new TCell();

            //t.

            foreach (TRowResult result in results)
            {
                //result.Columns[column]
                //result.Columns;

                hbaseResult = result.Columns;

                //string s = Encoding.UTF8.GetString(result.Columns[column].Value);

                //foreach (KeyValuePair<byte[], TCell> singleRow in konj)
                //{
                //    //File.WriteAllBytes(@"c:\test\output.docx", singleRow.Value.Value);
                //    Main a = new Main();
                //    a.OpenFile(singleRow.Value.Value, "output.docx");
                //}
            }
            return(hbaseResult);
        }
Ejemplo n.º 17
0
        public Dictionary<byte[], TCell> GetHBaseImage()
        {
            var socket = new TSocket(_hbaseThrif, _hbaseThrifPort);
            var transport = new TBufferedTransport(socket);
            var protocol = new TBinaryProtocol(transport);
            Hbase.Client hbaseClient = new Hbase.Client(protocol);
            Dictionary<byte[], TCell> hbaseResult = new Dictionary<byte[], TCell>();
            transport.Open();

            //List<byte[]> tableNames = hc.getTableNames();

            byte[] table = Encoding.UTF8.GetBytes("FiservImages");
            byte[] row = Encoding.UTF8.GetBytes(_documentId);
            byte[] column = Encoding.UTF8.GetBytes("ImageData:Image");

            List<TRowResult> results = hbaseClient.getRow(table, row, null);
            TCell t = new TCell();
            //t.

            foreach (TRowResult result in results)
            {
                //result.Columns[column]
                //result.Columns;

                hbaseResult = result.Columns;

                //string s = Encoding.UTF8.GetString(result.Columns[column].Value);

                //foreach (KeyValuePair<byte[], TCell> singleRow in konj)
                //{
                //    //File.WriteAllBytes(@"c:\test\output.docx", singleRow.Value.Value);
                //    Main a = new Main();
                //    a.OpenFile(singleRow.Value.Value, "output.docx");
                //}
            }
            return hbaseResult;
        }
Ejemplo n.º 18
0
        public void GetHBaseImage(string rowKey = "20150822180801118")
        {
            var socket    = new TSocket(hbaseThrif, hbaseThrifPort);
            var transport = new TBufferedTransport(socket);
            var protocol  = new TBinaryProtocol(transport);

            Hbase.Client hbaseClient = new Hbase.Client(protocol);
            transport.Open();

            //List<byte[]> tableNames = hc.getTableNames();

            byte[] table  = Encoding.UTF8.GetBytes("FiservImages");
            byte[] row    = Encoding.UTF8.GetBytes(rowKey);
            byte[] column = Encoding.UTF8.GetBytes("ImageData:Image");

            List <TRowResult> results = hbaseClient.getRow(table, row, null);
            TCell             t       = new TCell();

            //t.

            foreach (TRowResult result in results)
            {
                //result.Columns[column]
                //result.Columns;
                Dictionary <byte[], TCell> konj;
                konj = result.Columns;

                //string s = Encoding.UTF8.GetString(result.Columns[column].Value);

                foreach (KeyValuePair <byte[], TCell> singleRow in konj)
                {
                    //File.WriteAllBytes(@"c:\test\output.docx", singleRow.Value.Value);
                    OpenFile(singleRow.Value.Value, "output.docx");
                }
            }
        }
Ejemplo n.º 19
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.String) {
           ColumnName = iprot.ReadBinary();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.Struct) {
           Cell = new TCell();
           Cell.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
Ejemplo n.º 20
0
 public void AddCell(TCell cell)
 {
     Cells.Add(cell);
     UpdateBounds(cell);
 }
Ejemplo n.º 21
0
 internal void Clear()
 {
     _tCell = TCell.No;
 }
Ejemplo n.º 22
0
    public void Read(TProtocol iprot)
    {
        iprot.IncrementRecursionDepth();
        try
        {
            TField field;
            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }
                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.String)
                    {
                        Row = iprot.ReadBinary();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.Map)
                    {
                        {
                            Columns = new Dictionary <byte[], TCell>();
                            TMap _map4 = iprot.ReadMapBegin();
                            for (int _i5 = 0; _i5 < _map4.Count; ++_i5)
                            {
                                byte[] _key6;
                                TCell  _val7;
                                _key6 = iprot.ReadBinary();
                                _val7 = new TCell();
                                _val7.Read(iprot);
                                Columns[_key6] = _val7;
                            }
                            iprot.ReadMapEnd();
                        }
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 3:
                    if (field.Type == TType.List)
                    {
                        {
                            SortedColumns = new List <TColumn>();
                            TList _list8 = iprot.ReadListBegin();
                            for (int _i9 = 0; _i9 < _list8.Count; ++_i9)
                            {
                                TColumn _elem10;
                                _elem10 = new TColumn();
                                _elem10.Read(iprot);
                                SortedColumns.Add(_elem10);
                            }
                            iprot.ReadListEnd();
                        }
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                default:
                    TProtocolUtil.Skip(iprot, field.Type);
                    break;
                }
                iprot.ReadFieldEnd();
            }
            iprot.ReadStructEnd();
        }
        finally
        {
            iprot.DecrementRecursionDepth();
        }
    }
Ejemplo n.º 23
0
    public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
    {
        iprot.IncrementRecursionDepth();
        try
        {
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);

            while (true)
            {
                field = await iprot.ReadFieldBeginAsync(cancellationToken);

                if (field.Type == TType.Stop)
                {
                    break;
                }

                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.String)
                    {
                        Row = await iprot.ReadBinaryAsync(cancellationToken);
                    }
                    else
                    {
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                    }
                    break;

                case 2:
                    if (field.Type == TType.Map)
                    {
                        {
                            Columns = new Dictionary <byte[], TCell>();
                            TMap _map4 = await iprot.ReadMapBeginAsync(cancellationToken);

                            for (int _i5 = 0; _i5 < _map4.Count; ++_i5)
                            {
                                byte[] _key6;
                                TCell  _val7;
                                _key6 = await iprot.ReadBinaryAsync(cancellationToken);

                                _val7 = new TCell();
                                await _val7.ReadAsync(iprot, cancellationToken);

                                Columns[_key6] = _val7;
                            }
                            await iprot.ReadMapEndAsync(cancellationToken);
                        }
                    }
                    else
                    {
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                    }
                    break;

                case 3:
                    if (field.Type == TType.List)
                    {
                        {
                            SortedColumns = new List <TColumn>();
                            TList _list8 = await iprot.ReadListBeginAsync(cancellationToken);

                            for (int _i9 = 0; _i9 < _list8.Count; ++_i9)
                            {
                                TColumn _elem10;
                                _elem10 = new TColumn();
                                await _elem10.ReadAsync(iprot, cancellationToken);

                                SortedColumns.Add(_elem10);
                            }
                            await iprot.ReadListEndAsync(cancellationToken);
                        }
                    }
                    else
                    {
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                    }
                    break;

                default:
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);

                    break;
                }

                await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
        }
        finally
        {
            iprot.DecrementRecursionDepth();
        }
    }
Ejemplo n.º 24
0
 /// <summary>
 /// Creates a new pair of cells.
 /// </summary>
 /// <param name="firstCell">First cell.</param>
 /// <param name="secondCell">Second cell.</param>
 public Pair(TCell firstCell, TCell secondCell)
 {
     this.FirstCell  = firstCell;
     this.SecondCell = secondCell;
 }
Ejemplo n.º 25
0
 protected internal CellInfo(int x, int y, TCell data)
 {
     X    = x;
     Y    = y;
     Data = data;
 }
Ejemplo n.º 26
0
 public static Dictionary <TCell, (int Dist, TCell From)> DijkstraFrom <TCell, TMid>(this IDijkstra <TCell, TMid> dijkstra, TCell start, Func <TCell, bool> valid = null)
 {
     return(dijkstra.Build().ComputeFrom(start, valid));
Ejemplo n.º 27
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 0:
         if (field.Type == TType.List) {
           {
             Success = new List<TCell>();
             TList _list65 = iprot.ReadListBegin();
             for( int _i66 = 0; _i66 < _list65.Count; ++_i66)
             {
               TCell _elem67 = new TCell();
               _elem67 = new TCell();
               _elem67.Read(iprot);
               Success.Add(_elem67);
             }
             iprot.ReadListEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 1:
         if (field.Type == TType.Struct) {
           Io = new IOError();
           Io.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
Ejemplo n.º 28
0
 public void Read(TProtocol iprot)
 {
     TField field;
     iprot.ReadStructBegin();
     while (true)
     {
       field = iprot.ReadFieldBegin();
       if (field.Type == TType.Stop) {
     break;
       }
       switch (field.ID)
       {
     case 1:
       if (field.Type == TType.String) {
         Row = iprot.ReadBinary();
       } else {
         TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 2:
       if (field.Type == TType.Map) {
         {
           Columns = new Dictionary<byte[], TCell>();
           TMap _map4 = iprot.ReadMapBegin();
           for( int _i5 = 0; _i5 < _map4.Count; ++_i5)
           {
             byte[] _key6;
             TCell _val7;
             _key6 = iprot.ReadBinary();
             _val7 = new TCell();
             _val7.Read(iprot);
             Columns[_key6] = _val7;
           }
           iprot.ReadMapEnd();
         }
       } else {
         TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     default:
       TProtocolUtil.Skip(iprot, field.Type);
       break;
       }
       iprot.ReadFieldEnd();
     }
     iprot.ReadStructEnd();
 }
Ejemplo n.º 29
0
        public ActionResult Export(int payId)
        {
            PaymentManager pm      = new PaymentManager();
            Payment        payment = pm.LoadPayment(payId);

            #region 动态模板
            TTemplate template = new TTemplate();
            TRow      R1       = new TRow();
            TRow      R2       = new TRow();
            int       index1   = 3;
            int       index2   = 3;
            TCell     A        = new TCell("PersonId", "ID", 0, 0); A.RowSpan = 2; A.Width = 1;
            TCell     B        = new TCell("PersonName", "姓名", 0, 1); B.RowSpan = 2;
            TCell     C        = new TCell("PersonCode", "身份证", 0, 2); C.RowSpan = 2;
            R1.Cells.Add(A);
            R1.Cells.Add(B);
            R1.Cells.Add(C);
            foreach (PayItemDO item in payment.Items)
            {
                TCell cell = new TCell();
                cell.Name    = item.ItemName;
                cell.Caption = item.ItemCaption;
                if (item.IsLeaf == true)
                {
                    //cell.Width = 50;
                }
                if (item.ParentId == 0)
                {
                    cell.RowIndex    = 0;
                    cell.ColumnIndex = index1;
                    int colspan = 1;
                    foreach (PayItemDO pi in payment.Items)
                    {
                        if (pi.ParentId == item.ItemId)
                        {
                            colspan++;
                        }
                    }
                    if (colspan == 1)
                    {
                        cell.RowSpan = 2;
                        index1++;
                        index2++;
                    }
                    else
                    {
                        cell.ColSpan = colspan - 1;
                        index1       = index1 + cell.ColSpan;
                    }
                    R1.Cells.Add(cell);
                }
                else
                {
                    cell.RowIndex    = 1;
                    cell.ColumnIndex = index2;
                    index2           = index2 + 1;
                    R2.Cells.Add(cell);
                }
            }

            TSheet tsheet = new TSheet();
            tsheet.Name  = "Sheet1";
            tsheet.Title = "Sheet1";
            tsheet.Head.Rows.Add(R1);
            tsheet.Head.Rows.Add(R2);
            template.Sheets.Add(tsheet);
            #endregion

            IExcel  excel = ExcelFactory.CreateDefault();
            DataSet ds    = new DataSet();
            payment.DataSource.TableName = "Sheet1";
            ds.Tables.Add(payment.DataSource);
            POIStream stream = new POIStream();
            stream.AllowClose = false;
            excel.Write(stream, template, ds, ExcelExtendType.XLSX);
            stream.AllowClose = true;
            byte[] buffer = new byte[stream.Length];
            stream.Position = 0;
            stream.Read(buffer, 0, buffer.Length);
            stream.Close();

            HttpResponse context = System.Web.HttpContext.Current.Response;
            try
            {
                context.ContentType = "application/ms-excel";
                context.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xlsx", HttpUtility.UrlEncode(payment.PayTitle, System.Text.Encoding.UTF8)));
                context.BinaryWrite(buffer);
                context.Flush();
                context.End();
            }
            catch (Exception ex)
            {
                context.ContentType = "text/plain";
                context.Write(ex.Message);
            }
            return(null);
        }