Пример #1
0
        static void Main(string[] args)
        {
            InitializeWorkbook();

            ISheet s = hssfworkbook.GetSheetAt(0);

            ICell cell = s.GetRow(4).GetCell(1);

            cell.CopyCellTo(3); //copy B5 to D5

            IRow c = s.GetRow(3);

            c.CopyCell(0, 1);   //copy A4 to B4

            s.CopyRow(0, 1);    //copy row A to row B, original row B will be moved to row C automatically
            WriteToFile();
        }
Пример #2
0
        private void InsertColumn(int afterColumn, int insertCount, ISheet destSheet)
        {
            if (insertCount <= 0)
            {
                return;
            }
            IEnumerator rowEnumerator = destSheet.GetRowEnumerator();
            {
                while (rowEnumerator.MoveNext())
                {
                    IRow row = rowEnumerator.Current as IRow;
                    for (int index = row.LastCellNum - 1; index > afterColumn && index > row.FirstCellNum; index--)
                    {
                        ICell cell = row.GetCell(index);
                        if (cell != null)
                        {
                            cell.CopyCellTo(index + insertCount);
                        }
                    }

                    for (int index = 1; index <= insertCount; index++)
                    {
                        ICell source = row.GetCell(afterColumn);
                        ICell dest   = row.GetCell(afterColumn + index);
                        if (dest != null)
                        {
                            dest.SetCellValue("");
                            if (row.RowNum == 0)
                            {
                                if (source != null)
                                {
                                    dest.SetCellValue(GetCellValue(source));
                                }
                            }
                            if (source != null)
                            {
                                CopyCell(source, dest, destSheet.Workbook);
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
 public ICell CopyCellTo(int targetIndex)
 {
     return(_cell.CopyCellTo(targetIndex));
 }