|
 |
|
เว็บ asp.net ขึ้น iis แล้วปริ้นออก excel ไม่ได้ ถ้ารันในโปรแกรมปริ้นได้ |
|
 |
|
|
 |
 |
|
Print Excel ใช้ Function อะไรครับ ใช้พวก interop หรือเปล่า ถ้าใช่ ให้ทำการแก้ไขพวก Permission ด้วยครับ
|
 |
 |
 |
 |
Date :
2014-02-06 14:24:09 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้โค้ดประมาณนี้ค่ะ ไม่รู้เรียกว่าอะไร
Code (VB.NET)
Private Sub report()
Try
Dim daChk As SqlDataAdapter
Dim title As String = ""
Dim addmem As String = ""
Dim telmem As String = ""
Dim i As Integer = 0
Dim j As Integer = 5
Dim ExcelApp As Excel.Application
Dim ExcelBooks As Excel.Workbook
Dim ExcelSheets As Excel.Worksheet
ExcelApp = New Excel.Application
Dim chartRange As Excel.Range
ExcelApp.Visible = True
ExcelBooks = ExcelApp.Workbooks.Add()
ExcelSheets = DirectCast(ExcelBooks.Worksheets(1), Excel.Worksheet)
conn.Close()
conn.Open()
Dim dsChk As New DataSet
Dim sqlselect As String = ""
Dim idagent As String = ""
Dim addagent As String = ""
chartRange = ExcelSheets.Range("A1", "I1")
chartRange.Font.Size = 18
chartRange.Font.Bold = True
chartRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter
chartRange.Merge()
chartRange.FormulaR1C1 = "Individual Competency Assessment Report (รายงานผลประเมินสมรรถนะความสามารถในบุคคล)"
'chartRange.HorizontalAlignment = 3
'chartRange.VerticalAlignment = 3
With ExcelSheets
.Columns.Font.Name = "Angsana New"
.Columns.Font.Size = 14
.Columns().ColumnWidth = 8
'.Range("A13").RowHeight = 13
.Range("A3").RowHeight = 13
'.Range("A13").RowHeight = 21
.Range("A34").RowHeight = 15
.Range("A35").RowHeight = 15
'.Range("A31").RowHeight = 17
'.Range("A32").RowHeight = 17
.Range("A33").RowHeight = 15
.Range("A2").Value = "ตำแหน่ง : " + txtPositionper.Text
.Range("A2").Font.Bold = True
.Range("A2").Font.Size = 13
.Range("A2").HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft
|
 |
 |
 |
 |
Date :
2014-02-06 15:09:18 |
By :
NJ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VBScript)
Dim m As Integer = 0
Dim n As Integer = 23
Dim func As String
Dim number3 As String
Dim expect3 As Double
Dim have3 As Double
Dim persen3 As String
For m = 0 To GridView3.Rows.Count - 1
number3 = CStr(m + 1)
func = GridView3.Rows(m).Cells(2).Text
expect3 = CDbl(GridView3.Rows(m).Cells(3).Text)
have3 = CDbl(GridView3.Rows(m).Cells(4).Text)
persen3 = GridView3.Rows(m).Cells(6).Text
.Range("A" & n.ToString()).Value = number3 + "." + func
.Range("A" & n.ToString()).HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft
.Range("G" & n.ToString()).Value = expect3
.Range("G" & n.ToString()).HorizontalAlignment = Excel.XlHAlign.xlHAlignRight
.Range("H" & n.ToString()).Value = have3
.Range("H" & n.ToString()).HorizontalAlignment = Excel.XlHAlign.xlHAlignRight
.Range("I" & n.ToString()).Value = persen3
.Range("I" & n.ToString()).HorizontalAlignment = Excel.XlHAlign.xlHAlignRight
n += 1
Next
chartRange = ExcelSheets.Range("A4", "F" & CDbl(j.ToString()) - 1)
chartRange.BorderAround(Excel.XlLineStyle.xlContinuous, _
Excel.XlBorderWeight.xlThin, Excel.XlColorIndex. _
xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic)
chartRange = ExcelSheets.Range("G4", "G" & CDbl(j.ToString()) - 1)
chartRange.BorderAround(Excel.XlLineStyle.xlContinuous, _
Excel.XlBorderWeight.xlThin, Excel.XlColorIndex. _
xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic)
chartRange = ExcelSheets.Range("H4", "H" & CDbl(j.ToString()) - 1)
chartRange.BorderAround(Excel.XlLineStyle.xlContinuous, _
Excel.XlBorderWeight.xlThin, Excel.XlColorIndex. _
xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic)
chartRange = ExcelSheets.Range("I4", "I" & CDbl(j.ToString()) - 1)
chartRange.BorderAround(Excel.XlLineStyle.xlContinuous, _
Excel.XlBorderWeight.xlThin, Excel.XlColorIndex. _
xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic)
|
 |
 |
 |
 |
Date :
2014-02-06 15:09:55 |
By :
NJ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง Add Reference แล้วก็ไม่ได้
มันต้องทำยังไงบ้างค่ะ ไปไมาถูกค่ะ
มันไม่ error นะ แต่มันไม่เรียกเปิด excel เลย
โค้ดเขียนไว้แล้ว ถ้ารันผ่านโปรแกรมปริ้นได้ แต่รันผ่านบราวเซอร์ที่ขึ้น server ปริ้นไม่ได้
|
 |
 |
 |
 |
Date :
2014-02-12 11:28:33 |
By :
T_T |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเอา ไฟล์ Excel Interlop ไปวางไว้บน server นะครับ ไว้ที่ๆ อยู่ของ project
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ไขนะครับ ไฟล์ Microsoft.Office.Interop.Excel.dll กับ Interop.Excel.dll
ไปวางไว้ที่ server ครับ
|
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|