473,465 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

unwanted HTML in tab-delimited file export

I am outputting a datatable to a tab-delimited file. This all works well
and good with 2 issues:

1) There is some data in my table that looks like this:
<a_tag>theData</a_tag>. I would like to be able to strip out the tags
before writing to the csv file

2) If there are 100 rows output, then the 102nd row has the HTML of the
..aspx webform that contains the button which calls the
tab-delimitedf-ile-writing function. How can I get rid of this? Here's my
code:

Public Sub btnCommunitiesExcel_OnClick(ByVal sender As System.Object, ByVal
e As System.EventArgs)
Dim ds As New DataSet
Dim da As New SqlDataAdapter(Session("savedCommunitiesSql"),
connection1.conString)
da.Fill(ds, "CommunitiesExcel")
Dim dt As DataTable = ds.Tables("CommunitiesExcel")
Response.ContentType = "application/ms-excel"
Response.AddHeader("Content-Disposition", "inline;filename=test.csv")
Response.Write(ConvertDtToTDF(dt))
End Sub
Private Function ConvertDtToTDF(ByVal dt As DataTable) As String

Dim dr As DataRow, ary() As Object, i As Integer
Dim iCol As Integer

'Output Column Headers
For iCol = 0 To dt.Columns.Count - 1
Response.Write(dt.Columns(iCol).ToString & vbTab)
Next

Response.Write(vbCrLf)

'Output Data
For Each dr In dt.Rows
ary = dr.ItemArray
For i = 0 To UBound(ary)
Response.Write(ary(i).ToString & vbTab)
Next
Response.Write(vbCrLf)
Next
End Function
Nov 19 '05 #1
2 979
Before the Response.Write, try putting a Response.Clear()
and After the Response.Write, try putting a Response.End().

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:ew**************@TK2MSFTNGP14.phx.gbl...
I am outputting a datatable to a tab-delimited file. This all works well
and good with 2 issues:

1) There is some data in my table that looks like this:
<a_tag>theData</a_tag>. I would like to be able to strip out the tags
before writing to the csv file

2) If there are 100 rows output, then the 102nd row has the HTML of the
.aspx webform that contains the button which calls the
tab-delimitedf-ile-writing function. How can I get rid of this? Here's
my code:

Public Sub btnCommunitiesExcel_OnClick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Dim ds As New DataSet
Dim da As New SqlDataAdapter(Session("savedCommunitiesSql"),
connection1.conString)
da.Fill(ds, "CommunitiesExcel")
Dim dt As DataTable = ds.Tables("CommunitiesExcel")
Response.ContentType = "application/ms-excel"
Response.AddHeader("Content-Disposition", "inline;filename=test.csv")
Response.Write(ConvertDtToTDF(dt))
End Sub
Private Function ConvertDtToTDF(ByVal dt As DataTable) As String

Dim dr As DataRow, ary() As Object, i As Integer
Dim iCol As Integer

'Output Column Headers
For iCol = 0 To dt.Columns.Count - 1
Response.Write(dt.Columns(iCol).ToString & vbTab)
Next

Response.Write(vbCrLf)

'Output Data
For Each dr In dt.Rows
ary = dr.ItemArray
For i = 0 To UBound(ary)
Response.Write(ary(i).ToString & vbTab)
Next
Response.Write(vbCrLf)
Next
End Function

Nov 19 '05 #2
Steve,

Ok, that worked!!

And what about getting rid of my <strong> tags?

_____
Glenn

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:ed**************@TK2MSFTNGP14.phx.gbl...
Before the Response.Write, try putting a Response.Clear()
and After the Response.Write, try putting a Response.End().

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:ew**************@TK2MSFTNGP14.phx.gbl...
I am outputting a datatable to a tab-delimited file. This all works well
and good with 2 issues:

1) There is some data in my table that looks like this:
<a_tag>theData</a_tag>. I would like to be able to strip out the tags
before writing to the csv file

2) If there are 100 rows output, then the 102nd row has the HTML of the
.aspx webform that contains the button which calls the
tab-delimitedf-ile-writing function. How can I get rid of this? Here's
my code:

Public Sub btnCommunitiesExcel_OnClick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Dim ds As New DataSet
Dim da As New SqlDataAdapter(Session("savedCommunitiesSql"),
connection1.conString)
da.Fill(ds, "CommunitiesExcel")
Dim dt As DataTable = ds.Tables("CommunitiesExcel")
Response.ContentType = "application/ms-excel"
Response.AddHeader("Content-Disposition", "inline;filename=test.csv")
Response.Write(ConvertDtToTDF(dt))
End Sub
Private Function ConvertDtToTDF(ByVal dt As DataTable) As String

Dim dr As DataRow, ary() As Object, i As Integer
Dim iCol As Integer

'Output Column Headers
For iCol = 0 To dt.Columns.Count - 1
Response.Write(dt.Columns(iCol).ToString & vbTab)
Next

Response.Write(vbCrLf)

'Output Data
For Each dr In dt.Rows
ary = dr.ItemArray
For i = 0 To UBound(ary)
Response.Write(ary(i).ToString & vbTab)
Next
Response.Write(vbCrLf)
Next
End Function


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: chris Jangelov | last post by:
It seems that opening a link in a new window isn't considered to be good practise in xhtml 1.1. The w3c validation service does not accept it and I have to downgrade those pages to...
9
by: Olav Tollefsen | last post by:
Take a look at: http://www.baldrian.no/HtmlPage.htm Why does the browser render some unwanted space (showing the background color) below the buttons (image) and above the blue cell? How can...
5
by: Daveo | last post by:
Hi there, I'm having a problem with my database changing the date that I enter in the format dd/mm/yyyy into American format. Bizarrely, when enter the date in a textbox it changes round, but if...
3
by: DC Gringo | last post by:
I have a panel that's inserting and unwanted <div> tag around it ...how can I disable that? <ASP:PANEL ID="pnlCentralAmerica" RUNAT="server" > <LI CLASS="rightSideBar"> <A...
5
by: Tom | last post by:
I am having a problem where an extra gap (whitespace, padding) appears in a table cell where I don't want it. The data fed in the table is via dynamic HTML, so the amount in the middle cell may...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.