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

  • SEARCH
  • Home
  • 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 6148561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:18:10+00:00 2026-05-23T19:18:10+00:00

VS 2008 / C#. On passing the File path of a Spreadsheet, i need

  • 0

VS 2008 / C#.

On passing the File path of a Spreadsheet, i need to rename the Sheet.

How to rename the Sheet1 of the Excel Sheet as “ABC”.

We exporting an Excel Sheet to the SQL Database. Records in the Excel Sheet are manually edited and updated by end user. Column Values can have different datatypes.

By default, a Spread Sheet will have three Sheets as Sheet1, Sheet2,Sheet3.

End Users, usually work on Sheet1. We need to maintain a static name for this Sheet1 which helps us to Export the Sheet1 to SQL Database.

If we renamed the Sheet1 as ABC, we are maintaining the same Name. We cant export default sheet as like that. Because, End users may change their name or stick with default name on it.

In order to avoid confusion, we decided to rename the Sheet1 of the Spread Sheet.

  • 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-05-23T19:18:12+00:00Added an answer on May 23, 2026 at 7:18 pm

    C# 3.0

    using Microsoft.Office.Interop.Excel;
    

    Then

    object oMissing = System.Reflection.Missing.Value;
    
    Microsoft.Office.Interop.Excel.ApplicationClass xl = new Microsoft.Office.Interop.Excel.ApplicationClass();
    
    Microsoft.Office.Interop.Excel.Workbook xlBook;
    Microsoft.Office.Interop.Excel.Worksheet xlSheet;
    
    string laPath = System.IO.Path.GetFullPath("C:\\ExcelSheet.xls");
    xlBook = (Workbook)xl.Workbooks.Open(laPath, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
    
    xlSheet = (Worksheet)xlBook.Worksheets.get_Item(1);
    xlSheet.Name = "CIAO";
    xlBook.Save();
    xl.Application.Workbooks.Close();
    

    C# 4.0+

    The difference is: no more System.Reflection.Missing.Value and using DLR (Dynamic Language Runtime)

    using System.IO;
    
    using Excel = Microsoft.Office.Interop.Excel;
    using Word = Microsoft.Office.Interop.Word;
    

    Then

    var excelFile = Path.GetFullPath("C:\\ExcelSheet.xls");
    var excel = new Excel.Application();
    var workbook = excel.Workbooks.Open(excelFile);
    var sheet = (Excel.Worksheet)workbook.Worksheets.Item[1]; // 1 is the first item, this is NOT a zero-based collection
    sheet.Name = DateTime.Now.ToString("yyyyMMddHHmmss");
    workbook.Save();
    excel.Application.Workbooks.Close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to insert numbers with decimals into a SQL Server 2008 database. It
I am am trying to construct a database in SQL Server 2008 R2 that
SSMS 2008 doesn't have SQL Intellisense when connected to SQL Server 2005! I know
I am simply trying to call a store procedure (SQL Server 2008) using C#
I have been investigating Table-Valued Parameters in SQL Server 2008, and I've discovered that
I am using sql server 2008 which is communicating to java web service which
I have a stored procedure in SQL Server 2008 that will insert a record
I'm using VS 2008 and need to read text files that have UTF-8 Chinese
This page from SQL Server 2008 BOL , talks about CLR Stored Procedures and
I am developing an app using c# and sql server 2008 to automate a

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.