在 asp.net 使用 excel
<system.web>
<identity impersonate="true" userName="Admin" password="pwd" />
userName 與password 打上可以執行excel的帳號與密碼
以上是使用excel 2003 函數的範例:(記得要將 excle的元件參考進來)
Option Strict Off
Imports System
Imports System.Reflection ' For Missing.Value and BindingFlags
Imports System.Runtime.InteropServices ' For COMException
Imports Microsoft.Office.Interop.Excel
Public Class ExTools
Private app As Application
Sub New()
app = New Application
End Sub
Public Function getNORMSINV(ByVal score As Double, ByVal aveScore As Double, ByVal STDEVScore As Double) As Double
Try
If app Is Nothing Then
app = New Application
End If
Return app.WorksheetFunction.NormSInv(app.WorksheetFunction.NormDist(score, aveScore, STDEVScore, True))
' app.Quit()
'Return d
Catch ex As Exception
app.Quit()
End Try
'Dim iWorksheetFunction1 As IWorksheetFunction
'Return iWorksheetFunction1.NormSInv(iWorksheetFunction1.NormDist(score, aveScore, STDEVScore, True))
End Function
Public Sub appQuit()
app.Quit()
End Sub
End Class
