//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); //Load template file Home inventory.xlsx from resource GrapeCity.Documents.Excel.Workbook source_workbook = new GrapeCity.Documents.Excel.Workbook(); var source_fileStream = this.GetResourceStream("xlsx\\Home inventory.xlsx"); source_workbook.Open(source_fileStream); //Hide gridline workbook.ActiveSheet.SheetView.DisplayGridlines = false; workbook.ActiveSheet.Range["A1"].Value = "Copy content from the first sheet of source workbook"; workbook.ActiveSheet.Range["A1"].Font.Color = Color.Red; workbook.ActiveSheet.Range["A1"].Font.Bold = true; var pasteOption = new PasteOption(); pasteOption.PasteType = PasteType.Default | PasteType.RowHeights | PasteType.ColumnWidths; source_workbook.ActiveSheet.GetUsedRange().Copy(workbook.ActiveSheet.Range["A2"], pasteOption); workbook.ActiveSheet.Range["C21"].Value = "Cut content from the second sheet of source workbook"; workbook.ActiveSheet.Range["C21"].Font.Color = Color.Red; workbook.ActiveSheet.Range["C21"].Font.Bold = true; //Cut content of second sheet from source workbook to the current sheet at C22 source_workbook.Worksheets[1].Range["2:15"].Cut(workbook.ActiveSheet.Range["C22"]); //Make the theme of two workbooks same workbook.Theme = source_workbook.Theme; // Save to an excel file workbook.Save("CutCopyRangeBetweenWorkbooks.xlsx");
' Create a new Workbook Dim workbook As New Workbook 'Load template file Home inventory.xlsx from resource Dim source_workbook As New Excel.Workbook Dim source_fileStream = GetResourceStream("Home inventory.xlsx") source_workbook.Open(source_fileStream) 'Hide gridline workbook.ActiveSheet.SheetView.DisplayGridlines = False workbook.ActiveSheet.Range!A1.Value = "Copy content from the first sheet of source workbook" workbook.ActiveSheet.Range!A1.Font.Color = Color.Red workbook.ActiveSheet.Range!A1.Font.Bold = True 'Copy content of active sheet from source workbook to the current sheet at A2 Dim pasteOption As PasteOption = New PasteOption() pasteOption.PasteType = PasteType.Default Or PasteType.RowHeights Or PasteType.ColumnWidths source_workbook.ActiveSheet.GetUsedRange().Copy(workbook.ActiveSheet.Range!A2, pasteOption) workbook.ActiveSheet.Range!C21.Value = "Cut content from the second sheet of source workbook" workbook.ActiveSheet.Range!C21.Font.Color = Color.Red workbook.ActiveSheet.Range!C21.Font.Bold = True 'Cut content of second sheet from source workbook to the current sheet at C22 source_workbook.Worksheets(1).Range("2:15").Cut(workbook.ActiveSheet.Range!C22) 'Make the theme of two workbooks same workbook.Theme = source_workbook.Theme ' save to an excel file workbook.Save("CutCopyRangeBetweenWorkbooks.xlsx")