请问导出excel问题,服务器本机可导,但在客户端调用服务器IP进行导出时出错。
ewen 2005-07-28 09:20:18 Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(strSql, conn)
Dim Ds As DataSet = New DataSet
Adapter.Fill(Ds, "temp")
Dim xlsheet As OWC.SpreadsheetClass = New OWC.SpreadsheetClass
Dim dt As DataTable = Ds.Tables("temp")
Dim numbercols As Int32 = dt.Columns.Count
'插入数据
Dim k As Int32
Dim y As Int32
'先导出标题
For k = 0 To dt.Rows.Count - 1
For y = 0 To numbercols - 1
xlsheet.ActiveSheet.Cells(k + 1, y + 1) = dt.Rows(k)(y).ToString
Next y
Next k
Dim strFilePath As String
Try
strFilePath = System.IO.Path.GetDirectoryName(Server.MapPath(Request.FilePath))
strFilePath = Replace(strFilePath, "\", "\\")
xlsheet.ActiveSheet.Export(strFilePath & "\\expExcel2.xls", OWC.SheetExportActionEnum.ssExportActionNone)
Catch ex As Exception
puFun.ShowMessage(Me, "数据导出excel文件失败!")
Finally
conn.Close()
conn = Nothing
Adapter = Nothing
Ds = Nothing
xlsheet = Nothing
End Try