|
-
Jun 17th, 2005, 12:18 AM
#1
Thread Starter
New Member
upload excel file
i tried to upload an excel file using the following code:
myWebClient.UploadFile("\\146.51.237.157 test\FromArray.xls", "POST", "C:\FromArray.xls")
The upload was successful but the content was changed into ASCII characters.
Please give me some advise. Thanks.
-
Jun 17th, 2005, 01:03 AM
#2
Re: upload excel file
I use this:
VB Code:
Imports System.Data
. . .
Dim cnnString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\Excel\test.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
Dim cnn As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand
Dim da As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
Try
cnn.ConnectionString = cnnString
cnn.Open()
cmd = cnn.CreateCommand
cmd.CommandText = "SELECT * FROM [Sheet1$]"
da.SelectCommand = cmd
da.Fill(ds, "ExcelSheet")
DataGrid1.DataSource = ds.Tables("ExcelSheet")
Catch oEx As Exception
Console.WriteLine(oEx.ToString)
Finally
cnn.Close()
End Try
-
Jun 22nd, 2005, 09:03 PM
#3
Thread Starter
New Member
Re: upload excel file
Thank you for your quick response.
We are using the WebClient class. Do you know how to upload using this class? The upload is actually successfull. The only problem is that the contents is changing during the process. This is my code:
Dim myWebClient As New WebClient
Dim strLocalFile As String = txtUploadFile.Text
Dim strServerPath As String = "\\146.51.237.157\test\"
Dim strFilename As String = fnGetFileName(strLocalFile)
Dim strServerLocation As Byte() = myWebClient.UploadFile(strServerPath + strFilename, "POST", strLocalFile)
Thank you very much for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|