コード例 #1
0
        public void CopyRange2Worksheet(int row, int sourceColumnIndex, int destinationColumnIndex, AsposeExcel destinationExcel)
        {
            List <Cell> list = new List <Cell>();

            for (int i = 0; i < row; i++)
            {
                list.Add(destinationExcel.CurrentWorksheet.Cells.GetCell(i, destinationColumnIndex));
            }

            destinationExcel.CurrentWorksheet.Cells.CopyColumn(CurrentWorksheet.Cells,
                                                               sourceColumnIndex, destinationColumnIndex);

            for (int i = 0; i < row; i++)
            {
                try
                {
                    destinationExcel.CurrentWorksheet.Cells.GetCell(i, destinationColumnIndex).PutValue(list[i].Value);
                }
                catch (NullReferenceException)
                {
                    //do nothing
                }
            }


            destinationExcel.CurrentWorksheet.AutoFitColumn(destinationColumnIndex);
        }
コード例 #2
0
        public void CopyRange2Worksheet(int sourceColumnIndex, int destinationColumnIndex, AsposeExcel destinationExcel)
        {
            destinationExcel.CurrentWorksheet.Cells.CopyColumn(CurrentWorksheet.Cells,
                                                               sourceColumnIndex, destinationColumnIndex);

            destinationExcel.CurrentWorksheet.AutoFitColumn(destinationColumnIndex);
        }