Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I am trying to export an image to excel i was succeed in that. What i am actually need is when i click on Export to excel its showing do you want to save the excel 'Book1'?

But i want to change the Default name as 'Book1' to some other name. I was used"Test";

Here i am getting an error. Can u people please tell me how to set name to workbook in ASP.Net

Thanks in Advance

Sandeep Paruchuru

1 solution

Here is InterOp code to rename the specific work book as:
using Excel = Microsoft.Office.Interop.Excel; 

    object oMissing = System.Reflection.Missing.Value;
    Excel.ApplicationClass xl=new Excel.ApplicationClass();
        Excel.Workbook xlBook;
        Excel.Worksheet xlSheet;
        string laPath = Server.MapPath(@"\excel\xl_table.xls");
        xlBook = (Workbook)xl.Workbooks.Open(laPath,oMissing,
          oMissing,oMissing,oMissing ,oMissing,oMissing,oMissing
         ,oMissing,oMissing,oMissing,oMissing,oMissi ng,oMissing,oMissing);
        xlSheet = (Worksheet)xlBook.Worksheets.get_Item(1);
        xlSheet.Name = "MyOwnSheet";
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900