468,117 Members | 2,205 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

question about StreamWriter

Hi,

i'm experientating with object StreamWriter in asp.net.
This code works: the string is written to an excel sheet, but i have a
questions about it:

how does asp.net know the string must be written to an excel sheet and not a
word or any other format: is this only determined by the file extention
(xls)?

Thanks
Eric

Dim objFileStream As FileStream
Dim objStreamWriter As StreamWriter

filePath = Server.MapPath("\myapp\excel")
fileName = filePath & "\myfile.xls"

objFileStream = New FileStream(fileName, FileMode.OpenOrCreate,
FileAccess.Write)
objStreamWriter = New StreamWriter(objFileStream)
objStreamWriter.WriteLine("this text goes into a excel sheet)
objStreamWriter.WriteLine("")
objStreamWriter.Close()
Nov 20 '08 #1
2 3346
it doesn't. its either a binary writer or text writer depending on the stream
type. it just writes whats put in it. in fact the StreamWriter your using
doesn't enen know its writing to a file. if you opened the file with notepad,
you'd just see the text, you wrote, and no excel markup.
-- bruce (sqlwork.com)
"Eric" wrote:
Hi,

i'm experientating with object StreamWriter in asp.net.
This code works: the string is written to an excel sheet, but i have a
questions about it:

how does asp.net know the string must be written to an excel sheet and not a
word or any other format: is this only determined by the file extention
(xls)?

Thanks
Eric

Dim objFileStream As FileStream
Dim objStreamWriter As StreamWriter

filePath = Server.MapPath("\myapp\excel")
fileName = filePath & "\myfile.xls"

objFileStream = New FileStream(fileName, FileMode.OpenOrCreate,
FileAccess.Write)
objStreamWriter = New StreamWriter(objFileStream)
objStreamWriter.WriteLine("this text goes into a excel sheet)
objStreamWriter.WriteLine("")
objStreamWriter.Close()
Nov 20 '08 #2
I remember there was some way of making it write to file in Excel
formatting...
I built a program that does that.

When I find it, I'll post on here.

-Maximz2005

On Nov 20, 1:52*pm, bruce barker
<brucebar...@discussions.microsoft.comwrote:
it doesn't. its either a binary writer or text writer depending on the stream
type. it just writes whats put in it. in fact the StreamWriter your using
doesn't enen know its writing to a file. if you opened the file with notepad,
you'd just see the text, you wrote, and no excel markup.

-- bruce (sqlwork.com)

"Eric" wrote:
Hi,
i'm experientating with object StreamWriter in asp.net.
This code works: the string is written to an excel sheet, but i have a
questions about it:
how does asp.net know the string must be written to an excel sheet and not a
word or any other format: is this only determined by the file extention
(xls)?
Thanks
Eric
Dim objFileStream As FileStream
Dim objStreamWriter As StreamWriter
filePath = Server.MapPath("\myapp\excel")
fileName = filePath & "\myfile.xls"
objFileStream = New FileStream(fileName, FileMode.OpenOrCreate,
FileAccess.Write)
objStreamWriter = New StreamWriter(objFileStream)
objStreamWriter.WriteLine("this text goes into a excel sheet)
objStreamWriter.WriteLine("")
objStreamWriter.Close()
Nov 21 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Mark | last post: by
18 posts views Thread by Nick Z. | last post: by
1 post views Thread by Rob T | last post: by
14 posts views Thread by Tiraman :-\) | last post: by
2 posts views Thread by David Buchan | last post: by
1 post views Thread by Anthony Nystrom | last post: by
16 posts views Thread by billsahiker | last post: by
22 posts views Thread by timor.super | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.