Here is the code
Imports MISService
Imports System.Math
Public Class ExportPcnsToExcel
Inherits PageBase
Protected WithEvents message As System.Web.UI.WebControls.Label
Protected WithEvents pcnTbl As System.Web.UI.HtmlControls.HtmlTable
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim ts As New MISService.WorkOrderService()
'
Response.Buffer = True
Response.AddHeader("Content-Disposition", "attachment;filename=" &
Request("wcell") & ".xls")
Response.ContentType = "application/vnd.ms-excel"
'
If Request("wcell") = "MidStream" Then
ExportMidStreamPCNS(Request("wcell"), Request("selIdx"))
End If
'
End Sub
Private Sub ExportMidStreamPCNS(ByVal workcell As String, ByVal sGrp As
String)
Dim ts As New TycoMISService.WorkOrderService()
Dim shwoLst As ArrayList
Dim pcnitem As PCN
Dim errForServerCom As Boolean
'
errForServerCom = False
Try
If sGrp = "0" Then
shwoLst = ts.GetPCNListByWorkCell(workcell)
Else
shwoLst = ts.GetPCNListByWorkCellAndSGroup(workcell, sGrp)
End If
Catch
errForServerCom = True
End Try
'
If errForServerCom = True Then
dprintf("Error in comminication with MIS Server")
Exit Sub
End If
'
If (shwoLst.Count() = 0) Then
dprintf("No PCN found for " & workcell & " workcell.")
Exit Sub
End If
'
If workcell = "MidStream" Or Request("wcell") = "Midstream" Then
FillMidStreamHeaders()
For Each pcnitem In shwoLst
ExportMidStreamData(pcnitem)
Next
End If
'
End Sub
Private Sub FillMidStreamHeaders()
Dim NodeNameRow As New HtmlTableRow()
Dim ActTextRow As New HtmlTableRow()
Dim CActTextRow As New HtmlTableRow()
Dim i As Integer
'first row
For i = 1 To 5
addTextCellPCN(0, "gen", "", NodeNameRow, "")
Next
'
addTextCellPCN(0, "gen", "", NodeNameRow, "ProductLine")
addTextCellPCN(0, "gen", "", NodeNameRow, "Family")
addTextCellPCN(0, "gen", "", NodeNameRow, "Group")
addTextCellPCN(0, "gen", "", NodeNameRow, "Yield")
addTextCellPCN(0, "gen", "", NodeNameRow, "TCF")
addTextCellPCN(0, "gen", "", NodeNameRow, "PPR")
addTextCellPCN(0, "gen", "", NodeNameRow, "PPLCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PPUCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PPOORLO")
addTextCellPCN(0, "gen", "", NodeNameRow, "PPOORHI")
addTextCellPCN(0, "gen", "", NodeNameRow, "PHR")
addTextCellPCN(0, "gen", "", NodeNameRow, "PHLCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PHUCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PHOORLO")
addTextCellPCN(0, "gen", "", NodeNameRow, "PHOORHI")
addTextCellPCN(0, "gen", "", NodeNameRow, "PTR")
addTextCellPCN(0, "gen", "", NodeNameRow, "PTLCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PTUCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PTOORLO")
addTextCellPCN(0, "gen", "", NodeNameRow, "PTOORHI")
addTextCellPCN(0, "gen", "", NodeNameRow, "PRR")
addTextCellPCN(0, "gen", "", NodeNameRow, "PBLCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PBUCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PBOORLO")
addTextCellPCN(0, "gen", "", NodeNameRow, "PBOORHI")
'add first row to table
pcnTbl.Controls.AddAt(0, NodeNameRow)
'second row
For i = 1 To 8
addTextCellPCN(0, "gen", "", ActTextRow, "")
Next
'
addTextCellCRSpanPCN(0, "gen", "", ActTextRow, "Non-Resistance
Data", 1, 2)
addTextCellCRSpanPCN(0, "gen", "", ActTextRow, "Post Punch MPM", 1, 5)
addTextCellCRSpanPCN(0, "gen", "", ActTextRow, "Post H/T MPM", 1, 5)
addTextCellCRSpanPCN(0, "gen", "", ActTextRow, "Post T/C MPM", 1, 5)
addTextCellCRSpanPCN(0, "gen", "", ActTextRow, "Post Resistance Sort
MPM", 1, 5)
'add second row to table
pcnTbl.Controls.AddAt(1, ActTextRow)
'third row
For i = 1 To 3
addTextCellPCN(0, "gen", "", CActTextRow, "")
Next
'
addTextCellPCN(0, "gen", "", CActTextRow, "RPN")
addTextCellPCN(0, "gen", "", CActTextRow, "Description")
addTextCellPCN(0, "gen", "", CActTextRow, "Family")
addTextCellPCN(0, "gen", "", CActTextRow, "Group")
addTextCellPCN(0, "gen", "", CActTextRow, "SubGrp")
addTextCellPCN(0, "gen", "", CActTextRow, "Yield")
addTextCellPCN(0, "gen", "", CActTextRow, "TCF")
'
For i = 1 To 4
addTextCellPCN(0, "gen", "", CActTextRow, "type")
addTextCellPCN(0, "gen", "", CActTextRow, "LSL")
addTextCellPCN(0, "gen", "", CActTextRow, "USL")
addTextCellPCN(0, "gen", "", CActTextRow, "LOOR")
addTextCellPCN(0, "gen", "", CActTextRow, "HOOR")
Next
'add third row
pcnTbl.Controls.AddAt(2, CActTextRow)
'
End Sub
Private Sub ExportMidStreamData(ByVal pcnitem As PCN)
Dim Ptr As New HtmlTableRow()
Dim idx As Integer
'
idx = pcnTbl.Rows.Count
'
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.WorkCell)
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.PcnType)
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.subGroup)
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.PCNNumber)
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.PcnDesc)
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.ProductLine)
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.Family)
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.Group)
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("Yield"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("TCF"))
'
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PPR"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PPLCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PPUCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PPOORLO"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PPOORHI"))
'
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PHR"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PHLCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PHUCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PHOORLO"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PHOORHI"))
'
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PTR"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PTLCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PTUCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PTOORLO"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PTOORHI"))
'
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PRR"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PBLCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PBUCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PBOORLO"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PBOORHI"))
'
pcnTbl.Controls.AddAt(idx, Ptr)
'
End Sub
Public Sub dprintf(ByVal msg As String)
If Len(message.Text) = 0 Then
message.Text = msg
Else
message.Text = message.Text & "<br>" & msg
End If
End Sub
Private Sub FillMidStreamHeaders()
Dim NodeNameRow As New HtmlTableRow()
Dim ActTextRow As New HtmlTableRow()
Dim CActTextRow As New HtmlTableRow()
Dim i As Integer
'first row
For i = 1 To 5
addTextCellPCN(0, "gen", "", NodeNameRow, "")
Next
'
addTextCellPCN(0, "gen", "", NodeNameRow, "ProductLine")
addTextCellPCN(0, "gen", "", NodeNameRow, "Family")
addTextCellPCN(0, "gen", "", NodeNameRow, "Group")
addTextCellPCN(0, "gen", "", NodeNameRow, "Yield")
addTextCellPCN(0, "gen", "", NodeNameRow, "TCF")
addTextCellPCN(0, "gen", "", NodeNameRow, "PPR")
addTextCellPCN(0, "gen", "", NodeNameRow, "PPLCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PPUCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PPOORLO")
addTextCellPCN(0, "gen", "", NodeNameRow, "PPOORHI")
addTextCellPCN(0, "gen", "", NodeNameRow, "PHR")
addTextCellPCN(0, "gen", "", NodeNameRow, "PHLCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PHUCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PHOORLO")
addTextCellPCN(0, "gen", "", NodeNameRow, "PHOORHI")
addTextCellPCN(0, "gen", "", NodeNameRow, "PTR")
addTextCellPCN(0, "gen", "", NodeNameRow, "PTLCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PTUCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PTOORLO")
addTextCellPCN(0, "gen", "", NodeNameRow, "PTOORHI")
addTextCellPCN(0, "gen", "", NodeNameRow, "PRR")
addTextCellPCN(0, "gen", "", NodeNameRow, "PBLCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PBUCL")
addTextCellPCN(0, "gen", "", NodeNameRow, "PBOORLO")
addTextCellPCN(0, "gen", "", NodeNameRow, "PBOORHI")
'add first row to table
pcnTbl.Controls.AddAt(0, NodeNameRow)
'second row
For i = 1 To 8
addTextCellPCN(0, "gen", "", ActTextRow, "")
Next
'
addTextCellCRSpanPCN(0, "gen", "", ActTextRow, "Non-Resistance
Data", 1, 2)
addTextCellCRSpanPCN(0, "gen", "", ActTextRow, "Post Punch MPM", 1, 5)
addTextCellCRSpanPCN(0, "gen", "", ActTextRow, "Post H/T MPM", 1, 5)
addTextCellCRSpanPCN(0, "gen", "", ActTextRow, "Post T/C MPM", 1, 5)
addTextCellCRSpanPCN(0, "gen", "", ActTextRow, "Post Resistance Sort
MPM", 1, 5)
'add second row to table
pcnTbl.Controls.AddAt(1, ActTextRow)
'third row
For i = 1 To 3
addTextCellPCN(0, "gen", "", CActTextRow, "")
Next
'
addTextCellPCN(0, "gen", "", CActTextRow, "RPN")
addTextCellPCN(0, "gen", "", CActTextRow, "Description")
addTextCellPCN(0, "gen", "", CActTextRow, "Family")
addTextCellPCN(0, "gen", "", CActTextRow, "Group")
addTextCellPCN(0, "gen", "", CActTextRow, "SubGrp")
addTextCellPCN(0, "gen", "", CActTextRow, "Yield")
addTextCellPCN(0, "gen", "", CActTextRow, "TCF")
'
For i = 1 To 4
addTextCellPCN(0, "gen", "", CActTextRow, "type")
addTextCellPCN(0, "gen", "", CActTextRow, "LSL")
addTextCellPCN(0, "gen", "", CActTextRow, "USL")
addTextCellPCN(0, "gen", "", CActTextRow, "LOOR")
addTextCellPCN(0, "gen", "", CActTextRow, "HOOR")
Next
'add third row
pcnTbl.Controls.AddAt(2, CActTextRow)
'
End Sub
Public Sub addTextCellPCN(ByVal idx As Integer, ByVal key As String,
ByVal href As String, ByRef Ptr As HtmlTableRow, ByVal txtStr As String)
Dim anch As New HtmlAnchor()
Dim Ptc1 As New HtmlTableCell()
Dim BgColor As String
'
If (href.Length <> 0) Then
anch.InnerText = txtStr
anch.HRef = href
Ptc1.Controls.Add(anch)
Else
Ptc1.InnerText = txtStr
End If
Ptc1.Align = "center"
Ptc1.BgColor = BgColor
Ptr.BgColor = BgColor
Ptr.Controls.Add(Ptc1)
End Sub
End Class
In the ExportMidStreamData procedure i am trying to display the data. if i
go and see the vaues of following at runtime it is showing me the "+/-" where
ever i have "+/-" in the database. After it exports data to excel, in excel
sheet it is not showing me "+/-"
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PPR"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PPLCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PPUCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PPOORLO"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PPOORHI"))
'
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PHR"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PHLCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PHUCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PHOORLO"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PHOORHI"))
'
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PTR"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PTLCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PTUCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PTOORLO"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PTOORHI"))
'
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PRR"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PBLCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PBUCL"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PBOORLO"))
addTextCellPCN(0, "KEY", "", Ptr, pcnitem.GetSetPointData("PBOORHI"))
if i remove following 3 lines of code from Page_Load event then data is
displaying on browser and there it is displaying "+/-".
Response.Buffer = True
Response.AddHeader("Content-Disposition", "attachment;filename=" &
Request("wcell") & ".xls")
Response.ContentType = "application/vnd.ms-excel"
Please Help me.