Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hai all,
 
I used the below code for renaming after the file uploaded to particular folder,but its working fine locally but its giving runtime error in server

 try
                     {
                         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;
                         xlBook = (Microsoft.Office.Interop.Excel.Workbook)xl.Workbooks.Open(fileLocation, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
                         xlSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlBook.Worksheets.get_Item(1);
                         xlSheet.Name = "New_LITM -" + 12;
                         xlBook.Save();
                         xl.Application.Workbooks.Close();
                     }
                     catch (Exception ex)
                     {
                         lblStatus.Visible = true;
                         lblStatus.Text = ex.Message;
                         lblStatus.ForeColor = System.Drawing.Color.Red;
                     }
 

 
please help me out this....
Posted 5-Dec-12 3:12am
Edited 5-Dec-12 3:16am
v2
Comments
Deenu India at 5-Dec-12 8:48am
   
Where is that error?????
ryanb31 at 5-Dec-12 9:57am
   
What's the error? If it works locally but not on the server it is often a permissions issue.
Malarpalanisamy at 12-Dec-12 2:32am
   
Run time error is appearing because of ms office is not installed on server level
thanks....

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Your code is certainly right. I suppose maybe two reasons: One is that you did not install MS Office components in your ftp. the second is even you install it,you have to do some complex configurations. So normally, it is not suggest to use MS Office on ftp.It is more reasonable to use other components. Here I can suggest you one MS Excel component[^],it supports to read your excel data and store it on ftp also you can directly use it on ftp and avoid doing complex configurations. hope you good luck.
  Permalink  
Comments
Malarpalanisamy at 12-Dec-12 2:31am
   
Thanks for giving suggestions

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 434
1 OriginalGriff 380
2 CHill60 240
3 Abhinav S 220
4 CPallini 220
0 Sascha Lefévre 75
1 OriginalGriff 70
2 F-ES Sitecore 55
3 Peter Leow 50
4 Dave Kreskowiak 40


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 5 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100