Chalalo Land

Tecnologías ASP.NET y un poco Más

Contacto


 Si quierer cooperar, yo feliz, muy agradecido :)

De donde me Visitan?

Locations of visitors to this page

Generic Content

Si te gustaron los articulos, y te animas te estaría muy agradecido!


Recent Posts

Tags

Community

Blogs de MVP

Amigos Geeks

Blogs Imperdibles

GODS

Archives

Email Notifications

Exportar Grilla a CSV – Migrado a VB.NET

Hola, primero que nada, quiero aclarar que no soy el Dueño de este código, de hecho un lector de mi blog me posteó el ejemplo que estaba en C#  y lo necesitaba en VB.NET. Resulta que al traducirlo automáticamente con el gran TELERIK Converter.

image

El articulo original está en:
http://www.arzion.com/empresa-de-internet/posts/Exportar-un-GridView-a-CSV-con-ASPnet
Realizado por Ernesto Traversaro

Luego al traducirlo el Lector lo probó y dijo:

image

Luego otra persona me dijo lo mismo y lo revisé y era simplemente que una variable se estaba declarando dos veces entonces lo cambié y resulto:

Protected Sub ExportarCSV()
        Response.Clear()
        Response.Buffer = True
        Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.csv")
        Response.Charset = ""
        Response.ContentType = "application/text"
        GridView1.AllowPaging = False
        GridView1.DataBind()
        Dim sb As New StringBuilder()
        Dim k As Integer = 0
        While k < GridView1.Columns.Count
            sb.Append(GridView1.Columns(k).HeaderText + ","c)
            System.Math.Max(System.Threading.Interlocked.Increment(k), k - 1)
        End While
        sb.Append(vbCr & vbLf)
        Dim i As Integer = 0
        While i < GridView1.Rows.Count
            Dim k2 As Integer = 0
            While k2 < GridView1.Columns.Count
                sb.Append(GridView1.Rows(i).Cells(k2).Text + ","c)
               System.Math.Max(System.Threading.Interlocked.Increment(k2), k2 - 1)
            End While
            sb.Append(vbCr & vbLf)
            System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
        End While
        Response.Output.Write(sb.ToString())
        Response.Flush()
        Response.End()
    End Sub

Entonces lo hice un ejemplo con VB.NET
PUEDES DESCARGARLO ACA

Y  si quieres ver el articulo original C# esta en:

http://www.arzion.com/empresa-de-internet/posts/Exportar-un-GridView-a-CSV-con-ASPnet

Saludos,
Gonzalo

Posted: 15/1/2010 3:34 por Gonzalo Perez | con 2 comment(s)
Archivado en: ,
Comparte este post:

Comentarios

Skar ha opinado:

Programen en c# las mijas

# January 15, 2010 8:04 PM

williams rodriguez ha opinado:

Facinante blog. Gracias por compartir tanta informacion :D

# January 19, 2010 2:41 PM