Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9173577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:36:41+00:00 2026-06-17T16:36:41+00:00

Hi everyone i have an excel file which i want to use as source

  • 0

Hi everyone i have an excel file which i want to use as source for new excel files.I saw some examples that can copy all sheets,however my problem is that i want to copy only selected sheets from the source file and create new file with the selected sheets. e.g. this would be like if my main table has sheets x,y,z,c,f,g and user selects z,f,g i will only select these three create a new .xlsx file and put them there.Is this possible with c#? thank you in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:36:42+00:00Added an answer on June 17, 2026 at 4:36 pm

    You can copy the selected sheets for example in VBA, The below will create a new workbook with selected sheets

    Sheets(Array("Sheet1", "Sheet3", "Sheet4")).Copy
    

    In C#, you can so the same thing as

        private void button1_Click(object sender, EventArgs e)
        {
            Excel.Application xlexcel;
            Excel.Workbook xlWorkBook;
            Excel.Sheets worksheets;
    
            object misValue = System.Reflection.Missing.Value;
    
            xlexcel = new Excel.Application();
    
            xlexcel.Visible = true;
    
            //~~> Open a File
            xlWorkBook = xlexcel.Workbooks.Open("C:\\Sample.xlsx", 0, true, 5, "", "", true,
            Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
    
            //~~> Specify the sheets you want to copy
            String[] selectedSheets = { "a", "c", "d" };
    
            //~~> Set your worksheets
            worksheets = xlWorkBook.Worksheets;
    
            //~~>Copy it. This will create a new Excel file with selected sheets
            ((Excel.Sheets)worksheets.get_Item(selectedSheets)).Copy();
    
        }
    

    Screenshot

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

everyone. I have some labels that I draw them in the xib file, and
Hi everyone i have one question i.e. i have some database table's which are
I have an m file which creates an excel file using xlswrite . If
everyone,i have a lot of files write to disk per seconds,i want to disable
everyone! I have a trouble. I tried to save excel file in jsf web
Hello everyone I use Excel 2010 with VB Ok so I have an issue
Hello everyone I have a problem. I want to do a GridView with a
I have a central git repository that everyone pushes to for testing and integration,
Hi everyone my problem today is I have a couple of buttons that slide
I have those code snippet that checks the fans table and gets everyone who

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.