473,385 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 21 '05 #1
2 1151
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 21 '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 21 '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...
6
by: madsgormlarsen | last post by:
Hi I want to place a logo in a table, but get a unwanted margin underneath the image. I have placed a blue box instead of the logo, so it is easy to se the problem. ...
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...
2
by: Robert Dickow | last post by:
I have some ASP.NET Web App pages on which there are web forms with textboxes and buttons for 'Cancel' and 'Submit' and such. All works great. However, it a user uses the ENTER key in either of two...
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...
16
by: lovecreatesbeauty | last post by:
/* When should we worry about the unwanted chars in input stream? Can we predicate this kind of behavior and prevent it before debugging and testing? What's the guideline for dealing with it? ...
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...
3
by: kingflux | last post by:
Hello, and thank you in advance for any help you can provide. Each line in our datagrid control contains a product number, description, and a textbox for the user to enter a quantity-to-order. ...
1
by: muthurama | last post by:
How to remove the unwanted space between two tables in the HTML
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.