主题:iis下-无法创建 ActiveX 组件
b/s 模式下 通过 Word.Document 实现打印 在.net2005开发环境下正常 部署到IIS上是报错"无法创建 ActiveX 组件",搞不清楚是什么原因造成的,那位高人指点一下!~~ 万分感谢
'按钮
<asp:Button ID="btnDY" runat="server" Text="打印" Width="67px" />
'调用打印方法如下:
Protected Sub btnDY_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDY.Click
buildDoc()
End Sub
Sub buildDoc()
Dim objWordDoc As Object
Dim i, j As Integer
Dim row, column As Integer
Dim Table As HtmlTable
Table = tb
row = Table.Rows.Count
column = Table.Rows(0).Cells.Count - 1
'column = Table.Rows(0).Cells.Count
'objWordDoc = New Microsoft.Office.Tools.Word.Document
objWordDoc = CreateObject("Word.Document")
Dim theArray(column, row)
Dim theRow(column)
For i = 0 To row - 1
For j = 0 To column - 1
'此处为临时代码,可优化 为什么数据行 使用 Table.Rows(i).Cells(j).InnerText 提取单元格数据会变成整行提取,不明白
If i > 0 Then
theRow = Table.Rows(i).Cells(j).InnerText.Split("</td><td>")
theArray(1, i + 1) = theRow(0)
theArray(2, i + 1) = String.Format(theRow(2)).Substring(3)
theArray(3, i + 1) = String.Format(theRow(4)).Substring(3)
theArray(4, i + 1) = String.Format(theRow(6)).Substring(3)
Exit For
Else
theArray(j + 1, i + 1) = Table.Rows(i).Cells(j).InnerText
End If
Next j
Next i
objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("工作考核报表")
objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("")
Dim rngPara As Object
rngPara = objWordDoc.Application.ActiveDocument.Paragraphs(1).Range
With rngPara
.Bold = True
.ParagraphFormat.Alignment = 1
.Font.Name = "Arial"
.Font.Size = 12
End With
Dim rngCurrent, tabCurrent As Object
rngCurrent = objWordDoc.Application.ActiveDocument.Paragraphs(3).Range
tabCurrent = objWordDoc.Application.ActiveDocument.Tables.Add(rngCurrent, row, column)
For i = 1 To column
objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.InsertAfter(theArray(i, 1).ToString.Trim())
objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.ParagraphFormat.alignment = 1
Next
For i = 1 To column
For j = 2 To row
objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.InsertAfter(theArray(i, j))
objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.ParagraphFormat.alignment = 1
Next
Next
'objWordDoc.Application.ActiveDocument.SaveAs()
objWordDoc.PrintOut(False)
'objWordDoc.Application.ActiveDocument.Close()
End Sub