public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Instantiate a new Workbook // Open an existing excel file Workbook workbook = new Workbook(dataDir + "aspose-sample.xlsx"); // Get the first worksheet Worksheet worksheet = workbook.Worksheets[0]; // Get the Cells collection Cells cells = worksheet.Cells; //Copy the first column to next 10 columns for (int i = 1; i <= 10; i++) { cells.CopyColumn(cells, 0, i); } // Save the excel file workbook.Save(dataDir + "outaspose-sample.out.xlsx"); // ExEnd:1 }
public static void Run() { //Source directory string sourceDir = RunExamples.Get_SourceDirectory(); //Output directory string outputDir = RunExamples.Get_OutputDirectory(); // Instantiate a new Workbook // Open an existing excel file Workbook workbook = new Workbook(sourceDir + "sampleCopyingSingleColumn.xlsx"); // Get the first worksheet Worksheet worksheet = workbook.Worksheets[0]; // Get the Cells collection Cells cells = worksheet.Cells; //Copy the first column to next 10 columns for (int i = 1; i <= 10; i++) { cells.CopyColumn(cells, 0, i); } // Save the excel file workbook.Save(outputDir + "outputCopyingSingleColumn.xlsx"); Console.WriteLine("CopyingSingleColumn executed successfully."); }
public static void Main() { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //Instantiate a new Workbook //Open an existing excel file Workbook workbook = new Workbook(dataDir + "aspose-sample.xlsx"); //Get the first worksheet Worksheet worksheet = workbook.Worksheets[0]; //Get the Cells collection Cells cells = worksheet.Cells; //Copy the first column to the third column cells.CopyColumn(cells, 0, 2); //Save the excel file workbook.Save(dataDir + "outaspose-sample.xlsx"); }