在网络浏览器中打开Excel文件 [英] Open a excel file in web browser
本文介绍了在网络浏览器中打开Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好...
我正在使用asp.net-2,当我单击打印"按钮时,我想在Web浏览器中打开一个excel文件.
我在localhost中配置时无法在安装文件中打开
Hi All...
am using asp.net-2 i want to open a excel file in the web browser when Print Button Click hear my code....
it couldnt open in setup file when i configure in localhost
Protected Sub btn_print_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_print.Click
Dim a As String = ""
Dim dsExport As New DataSet()
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Dim dgGrid As New DataGrid()
Dim xlWorkBook As Excel.Workbook
Dim xlApp As Excel.Application = New Excel.Application
'Dim xls As Excel.Worksheet
xlWorkBook = New Excel.Application().Workbooks.Add(True)
xlWorkBook.Application.Visible = False
Dim xls As Excel.Worksheet = CType(xlWorkBook.Worksheets(1), Excel.Worksheet)
xls = xlWorkBook.ActiveSheet
xls.Cells(3, 1) = ("Materials Received Note")
xls.Range("A3").Resize(1, 9).Cells.HorizontalAlignment = 3
xls.Range("A3").Resize(1, 9).Cells.MergeCells = True
xls.Cells(3, 1).font.size = 18
xls.Cells(3, 1).font.Bold = False
:
:
:
xls.Range("G17", "G39").Columns.AutoFit()
xls.Range("A17", "A39").Columns.AutoFit()
xls.Range("D11", "D15").Columns.AutoFit()
xls.Range("A11", "B15").Columns.AutoFit()
xls.Range("I11", "I15").Columns.AutoFit()
推荐答案
最简单的方法它是Response.Redirect(urlOfExcelFileOnServer).这样会将xl文件提供给客户端.
The easiest way to do it is to Response.Redirect(urlOfExcelFileOnServer). That will serve the xl file to the client.
这篇关于在网络浏览器中打开Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文