tinomesa Posted July 18, 2003 Posted July 18, 2003 Hello! I am trying to rename a sheet in an excel workbook. I have uploaded the sheet from the client, and I have saved it as a combination of the userID and a number. the problem is that I need to rename "Sheet1" or whatever the user named it to something else. I don't even know where to begin.... Any ideas?? Upload / saved Code: Sub uploadFile(ByVal source As Object, ByVal e As EventArgs) Dim mytempdb, TempTable As String mytempdb = Request.Cookies("APLoad_User").Value.ToString() TempTable = mytempdb.Remove(mytempdb.LastIndexOf(" "), 1) If Not IsDBNull(fileToUpload.PostedFile) Then Try fileToUpload.PostedFile.SaveAs("d:\inetpub\wwwroot\apload\apload\" + TempTable + ".XLS") Dim html As String = "<p>File uploaded successfully on the web server</p>" :confused: :confused: Quote
MrDuke Posted July 23, 2003 Posted July 23, 2003 This code i writed in c#, you should not have problems to translate it in Vb, however I had to have ... I am here! using 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,oMissing,oMissing,oMissing); xlSheet = (Worksheet)xlBook.Worksheets.get_Item(1); xlSheet.Name = "CIAO"; xlBook.Save(); xl.Application.Workbooks.Close(); Maurizio Quote
Recommended Posts