Clone Excel WorkSheet with radion buttons and add to workbook C# RRS feed

  • Question

  • Hi Friends,

    I need to clone Excel Worksheet and add to the workbook.

    Current worksheet has some radio button too, that also needs to be moved to new worksheet.

    Is is possible with CloseXML or OpenXML, If not any other suggestions.

    Kindly assist.

    Tuesday, June 5, 2018 7:33 AM

All replies

  • Hello Jagadish12345,

    If you have installed Excel application in your pc, it will be easy to use Microsoft.Office.Interop.Excel dll to copy the whole worksheet in C#.

    Such as

     string soureFilePath = @"C:\Users\Admin\Desktop\TestFolder\111.xlsx";
                Microsoft.Office.Interop.Excel.Application xlApplication = new Microsoft.Office.Interop.Excel.Application();
                xlApplication.Visible = true;
                Microsoft.Office.Interop.Excel.Workbook workbook = xlApplication.Workbooks.Open(soureFilePath);
                Microsoft.Office.Interop.Excel.Worksheet sourceSheet = workbook.Worksheets["Sheet1"];
                Microsoft.Office.Interop.Excel.Worksheet targetSheet;
                sourceSheet.Copy(Before: workbook.Sheets[1]);
                targetSheet = workbook.Sheets[1];
                targetSheet.Name = "CopyedSheet";

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Tuesday, June 5, 2018 9:01 AM
  • Hi Jagadish12345,

    If you do not have Excel installed, maybe you can use 3rd party libraries such as free Spire.XLS to achieve this purpose. At first, get free spire.xls dll from NuGet, second, refer to the following code:

    Workbook workbook = new Workbook(); workbook.LoadFromFile(@"Input.xls"); //Get the first sheet Worksheet sheet = workbook.Worksheets[0]; //add a new sheet Worksheet newSheet = workbook.Worksheets.Add("copied sheet1"); //copy the first sheet to the new added sheet

    newSheet.CopyFrom(sheet); workbook.SaveToFile(@"copy worksheet.xlsx",ExcelVersion.Version2013);

    • Edited by LeonDav Thursday, June 7, 2018 3:08 AM
    Thursday, June 7, 2018 3:07 AM