question about StreamWriter

E

Eric

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()
 
B

bruce barker

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)
 
M

maximz2005

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
 
G

George

open file myfile.xls with notepad....
Just because file has an extension of .xls does not mean it's in Excel
format.

Excel is just robust enough to show the string that is in the file. I bet
Word will do the same if you rename the file to myfile.doc

George.
 
E

Eric

indeed

George said:
open file myfile.xls with notepad....
Just because file has an extension of .xls does not mean it's in Excel
format.

Excel is just robust enough to show the string that is in the file. I bet
Word will do the same if you rename the file to myfile.doc

George.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top