Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

Posted

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...