We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issues with ASPOSE.CELLS

Hello,

We have published our site to the web. However, we are experiencing issues. What we are trying to do is have a user select a file to upload then have aspose process that document. The problem is the project works locally, but when we publish to the server, we are having issues. It is having an issue getting the file we are uploading. Here is our code.

Imports System.Xml

Imports System.Xml.Schema

Imports System.Data.SqlClient

Imports System.Web.Configuration

Imports System.Net

Imports Aspose.Cells

Imports Telerik.WebControls

Imports System.Threading

Imports MattBerseth.WebControls.AJAX.Progress

Imports System.Data

Imports System.Data.OleDb

Partial Class _Default

Inherits System.Web.UI.Page

Public nCount As Double

Public sourceConnection As SqlConnection

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim license As Aspose.Cells.License = New Aspose.Cells.License()

license.SetLicense("Aspose.Cells.lic")

If Not Page.IsPostBack Then

Dim UserName As String

UserName = IsAllowed()

Me.lblTodaysDate.Text = DateTime.Now

Me.lblUserName.Text = UserName

End If

End Sub

Public Function PostPage(ByVal url As String, ByVal payload As String) As String

Dim xmlString As String = payload

Dim result As String = vbNullString

Dim myxmldoc As New XmlDocument

Try

Dim client As New WebClient()

client.Headers.Add("Content-Type", "application/x-www-form-urlencoded")

Dim request As Byte() = Encoding.ASCII.GetBytes(xmlString)

Dim response As Byte() = client.UploadData(url, "POST", request)

result = Encoding.UTF8.GetString(response)

'The myxmldoc now holds the results

myxmldoc.LoadXml(result)

PostPage = GetStatus(myxmldoc)

Catch ex As Exception

' Response.Write(ex.Message)

PostPage = "ServerError"

End Try

End Function

Function GetStatus(ByVal m_xmld As XmlDocument) As String

Dim descriptionValue As String

descriptionValue = ""

Try

' Dim m_xmld As XmlDocument

Dim m_nodelist As XmlNodeList

Dim m_node As XmlNode

m_nodelist = m_xmld.SelectNodes("/TrackResponse/Shipment/Package/Activity/Status/StatusType")

'Loop through the nodes

For Each m_node In m_nodelist

'Get the firstName Element Value

descriptionValue = m_node.ChildNodes.Item(1).InnerText

Next

Catch errorVariable As Exception

End Try

Return descriptionValue

End Function

Function IsAllowed() As String

Dim UserName As String

Dim StartNum As Integer

Dim EmpNameLength As Integer

UserName = User.Identity.Name

'UserName = "ipgna\tara.perry"

'StartNum is always 6 b/c it's always "IPGNA\"

StartNum = 6

EmpNameLength = UserName.Length - StartNum

UserName = UserName.Substring(StartNum, EmpNameLength)

If UserName = "tara.perry" Then

'Allow

ElseIf UserName = "john.young" Then

'Allow

ElseIf UserName = "annette.varndell" Then

'Allow

ElseIf UserName = "frank.king" Then

'Allow

ElseIf UserName = "jim.hahn" Then

'Allow

ElseIf UserName = "isaac.apea" Then

'Allow

Else

'Do not Allow

' Response.Redirect("NoAccess.aspx")

End If

IsAllowed = UserName

End Function

Protected Sub UpdateFile()

Dim strPayload As String

Dim cInvoice As String

Dim cTrack As String

Dim xResult As String

Dim nRow As Double

Dim cProject As String

Dim ctask As String

Dim Result As String

nCount = 0

'Reset Import Rows label

'txtLabel.Text = "Starting..."

'Get the uploaded file

Dim FileName As String

FileName = ""

For Each f As UploadedFile In RadUpload1.UploadedFiles

FileName = f.FileName 'This gets c:\Documents and Settings\annette.varndell\desktop\0009212008.xls

Next

Dim x As Double

Dim workbook As Workbook = New Workbook()

'Calling Open method of Workbook object to open an Excel file using its file path

workbook.Open(FileName) 'Here is where the issue is. It can't find the file

Dim worksheet As Worksheet = workbook.Worksheets(0)

' Column 6 is Tracking

' Column 8 is Status

Dim cells As Cells = worksheet.Cells

Dim cVersion As String

' x = cells.EndCellInColumn(7).Row

x = cells.End.Row + 1

lblTotal.Text = x.ToString

Session("TotalCount") = x

Me.lblTodaysDate.Text = "rows"

For nRow = 1 To x

TryAgain:

xResult = ""

cVersion = worksheet.Cells(nRow, 0).StringValue

If cVersion = "3" Then

cTrack = worksheet.Cells(nRow, 6).StringValue

cInvoice = worksheet.Cells(nRow, 3).StringValue

Else

cTrack = worksheet.Cells(nRow, 19).StringValue

cInvoice = worksheet.Cells(nRow, 5).StringValue

End If

If Trim(cInvoice) = "" Then

Exit For

End If

If Trim(cTrack) <> "" Then

strPayload = "<?xml version='1.0'?>"

strPayload += ""

strPayload += " FC29B7AF62510F30"

strPayload += " jygoalkeeper"

strPayload += " Password99"

strPayload += ""

strPayload += "<?xml version=""1.0""?>"

strPayload += ""

strPayload += ""

strPayload += ""

strPayload += ""

strPayload += "guidlikesubstance"

strPayload += ""

strPayload += "1.0"

strPayload += ""

strPayload += "Track"

strPayload += ""

strPayload += "" + cTrack + ""

strPayload += ""

xResult = PostPage("HTTPS://www.ups.com/ups.app/xml/Track", strPayload)

If cVersion = "3" Then

worksheet.Cells(nRow, 8).PutValue(xResult)

Else

worksheet.Cells(nRow, 8).PutValue(xResult)

End If

End If

If xResult <> "ServerError" Then

nCount = nCount + 1

cProject = worksheet.Cells(nRow, 10).StringValue

cProject = Trim(Mid(cProject, 1, 4) + Mid(cProject, 6, 3) + Mid(cProject, 10, 2))

ctask = worksheet.Cells(nRow, 11).StringValue

ctask = Mid(ctask, 1, 3) + Mid(ctask, 5, 3)

If Mid(ctask, 6, 1) <> "-" And ctask <> "" Then

Result = VerifySubAccount(cProject, ctask)

If ctask <> Result Then

' uh oh

If cVersion = "3" Then

worksheet.Cells(nRow, 124).PutValue(Result)

Else

worksheet.Cells(nRow, 235).PutValue(Result)

End If

End If

End If

Session("status") = (nCount / x) * 100

Session("thecount") = nCount

Me.ProgressControl2.Value = nCount

Else

GoTo TryAgain

End If

Next

Me.lblTodaysDate.Text = "cell done"

Call workbook.Save(FileName)

Button1.Enabled = True

TimerControl1.Enabled = False

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Session.Add("status", 0)

Session.Add("thecount", 0)

Session.Add("totalcount", 0)

ConnectToSQL()

Dim objThread As New Thread(New System.Threading.ThreadStart(AddressOf UpdateFile))

objThread.IsBackground = True

objThread.Start()

Session("Thread") = objThread

Me.ProgressControl2.Visible = True

Button1.Enabled = False

TimerControl1.Enabled = True

End Sub

Protected Sub TimerControl1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TimerControl1.Tick

Dim i As Integer = CType(Session.Item("status"), Integer)

Dim y As Integer = CType(Session.Item("thecount"), Integer)

Dim nTotal As Integer = CType(Session.Item("totalcount"), Integer)

Me.ProgressControl2.Value = i

lblRecord.Text = y.ToString

lblTotal.Text = nTotal.ToString

UpdatePanel1.Update()

If y = nTotal And nTotal <> 0 Then

' TimerControl1.Enabled = False

Button1.Enabled = True

End If

End Sub

Protected Sub ConnectToSQL()

Dim sSqlConnectionString As String = ConfigurationManager.ConnectionStrings("OctagonDatabase").ConnectionString

sourceConnection = New SqlConnection(sSqlConnectionString)

Dim myDataset As New DataSet()

End Sub

Protected Function VerifySubAccount(ByVal cProject As String, ByVal cSub As String) As String

Dim result As Integer

Try

sourceConnection.Open()

sourceConnection.Close()

Catch ex As Exception

'Response.Redirect("Error.aspx")

End Try

sourceConnection.Open()

Dim sqlStatement As String

sqlStatement = "select count(*) from pjpent where project = " & cProject & " and pjt_entity = " & cSub & ""

Dim AddComm As New Data.SqlClient.SqlCommand(sqlStatement, sourceConnection)

result = AddComm.ExecuteScalar()

If result > 0 Then

VerifySubAccount = cSub

Else

cSub = "361000"

sqlStatement = "select count(*) from pjpent where project = " & cProject & " and pjt_entity = " & cSub & ""

AddComm = New Data.SqlClient.SqlCommand(sqlStatement, sourceConnection)

result = AddComm.ExecuteScalar()

If result > 0 Then

VerifySubAccount = cSub

Else

cSub = "700361"

sqlStatement = "select count(*) from pjpent where project = " & cProject & " and pjt_entity = " & cSub & ""

AddComm = New Data.SqlClient.SqlCommand(sqlStatement, sourceConnection)

result = AddComm.ExecuteScalar()

If result > 0 Then

VerifySubAccount = cSub

Else

VerifySubAccount = "Error"

End If

End If

End If

sourceConnection.Close()

Return VerifySubAccount

End Function

End Class

Your server doesn’t have access to the file, it’s on your local machine, so when you run it there you can’t get to the file. Save the file in a temp directory on the server and delete it when your processing is done.

Hi,

Aspose.Cells component does nothing with security configurations on a system. Well, I think, it might be the access rights problem for "'c:\Documents and Settings\annette.varndell\desktop\0009212008.xls" folder/file Kindly make sure that you allows proper rights to browse and access the local files system.

Thank you.