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

Free Support Forum - aspose.com

"The process cannot access the file 'test.xls' because it is being use by another process" exception occurred in .NET

Hi, we are on final test.


When some users click the button at the same time,

it shows an error like this attached png file.

And here is my vb.net code.


Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.IO
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Aspose.Cells

Partial Public Class _convertworkbooktopdffile
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)


End Sub
Protected Sub btnExecute_Click(ByVal sender As Object, ByVal e As EventArgs)

PutValue()

CreateStaticReport()

End Sub

Public Sub PutValue()

'Open template
Dim path As String = System.Web.HttpContext.Current.Server.MapPath("~")
path = path.Substring(0, path.LastIndexOf(""))
path &= “\test.xls”

'Instantiate a new Workbook object.
Dim book As New Workbook(path)

'Adding a new worksheet to the Excel object
Dim i As Integer = book.Worksheets.Add()

'Obtaining the reference of the newly added worksheet by passing its sheet index
i = 4

Dim worksheet As Worksheet = book.Worksheets(i)

worksheet.Cells(“G9”).Value = TextBox1.Text

book.Save(path)

End Sub


Public Shared Sub CreateStaticReport()

'Open template
Dim path As String = System.Web.HttpContext.Current.Server.MapPath("~")
path = path.Substring(0, path.LastIndexOf(""))
path &= “\test.xls”

'Instantiate a new Workbook object.
Dim book As New Workbook(path)

'Save the workbook as a PDF File
book.Save(HttpContext.Current.Response, “Xls2Pdf.pdf”, ContentDisposition.Attachment, New XlsSaveOptions(SaveFormat.Pdf))

'End response to avoid unneeded html after xls
HttpContext.Current.Response.End()

End Sub

End Class



Best,
<span lang=“EN-GB” style=“font-size:9.0pt;font-family:
“Arial”,“sans-serif”;color:#002776;mso-ansi-language:EN-GB”>Eric Ahn
Staff | Tax

<span lang=“EN-GB” style=“font-size:8.0pt;font-family:“Arial”,“sans-serif”;
color:#002776;mso-ansi-language:EN-GB”>
Deloitte Anjin LLC

5Fl., One IFC, 23, Yoido-dong, Youngdeungpo-gu, Seoul, 150-945, Korea<o:p></o:p>

Direct: +82 (2) 6099 4329 | Fax: +82 (2) 6674 2420
kahn@deloitte.com | www.deloitteanjin.co.kr

P Please consider the environment before printing

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We are unable to run your provided code. Please provide us your runnable sample project to look into this issue. We will investigate your issue at our end and help you asap.