question about StreamWriter

  • Thread starter Thread starter Eric
  • Start date Start date
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()
 
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)
 
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
 
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.
 
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.
 
Back
Top