Imports System
Imports System.Web.UI.WebControls
Imports System.Web.Security
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Data.OleDb
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports iTextSharp.text.html
Imports iTextSharp.text.html.simpleparser
Imports ExportToExcelClass
Public Class Result
Inherits System.Web.UI.Page
Private Sub btCSV_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btCSV.Click
'GridviewToExcel.Export("PK_QIS_" & DateTime.Now.ToString("yyyy_MM_dd") & ".xls", myGridView)
Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport_" + DateTime.Now.ToString("ddMMyyyy") + ".xls")
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Dim sw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(sw)
gvResult.AllowPaging = False
BindData(FromDT.Text, ToDT.Text, FromTime.SelectedValue, ToTime.SelectedValue, Line.SelectedValue, PPU.SelectedValue, ToolNo.SelectedValue, ToolSQ.SelectedValue, ToolType.SelectedValue, ByPass.SelectedValue, VINNumber.Text, Lotcode.Text, strFields, Sequence.Text)
'Change the Header Row back to white color
gvResult.HeaderRow.Style.Clear()
gvResult.HeaderRow.Style.Add("background-color", "#999999")
gvResult.HeaderRow.ForeColor = Drawing.Color.White
'Apply style to Individual Cells
'myGridView.HeaderRow.Cells(0).Style.Add("background-color", "#1d1d1d")
'myGridView.HeaderRow.Cells(1).Style.Add("background-color", "#1d1d1d")
'myGridView.HeaderRow.Cells(2).Style.Add("background-color", "#1d1d1d")
'myGridView.HeaderRow.Cells(3).Style.Add("background-color", "green")
For i As Integer = 0 To gvResult.Rows.Count - 1
Dim row As GridViewRow = gvResult.Rows(i)
'Change Color back to white
row.BackColor = System.Drawing.Color.FromArgb(201, 201, 201)
row.ForeColor = System.Drawing.Color.Black
'Apply text style to each Row
row.Attributes.Add("class", "textmode")
'Apply style to Individual Cells of Alternating Row
If i Mod 2 <> 0 Then
'row.Cells(0).Style.Add("background-color", "#1d1d1d")
'row.Cells(1).Style.Add("background-color", "#C2D69B")
'row.Cells(2).Style.Add("background-color", "#C2D69B")
'row.Cells(3).Style.Add("background-color", "#C2D69B")
row.Style.Add("background-color", "#f0f0f0")
End If
Next
gvResult.RenderControl(hw)
'style to format numbers to string
Dim style As String = "<style> .textmode { mso-number-format:\@; } </style>"
Response.Write(style)
Response.Output.Write(sw.ToString())
Response.Flush()
Response.End()
End Sub
Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
' Verifies that the control is rendered
Return
End Sub
Tag : .NET, Ms SQL Server 2008, HTML/CSS, VS 2008 (.NET 3.x)