question about StreamWriter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric

    #1

    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\exc el")
    fileName = filePath & "\myfile.xl s"

    objFileStream = New FileStream(file Name, FileMode.OpenOr Create,
    FileAccess.Writ e)
    objStreamWriter = New StreamWriter(ob jFileStream)
    objStreamWriter .WriteLine("thi s text goes into a excel sheet)
    objStreamWriter .WriteLine("")
    objStreamWriter .Close()


  • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

    #2
    RE: question about StreamWriter

    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\exc el")
    fileName = filePath & "\myfile.xl s"
    >
    objFileStream = New FileStream(file Name, FileMode.OpenOr Create,
    FileAccess.Writ e)
    objStreamWriter = New StreamWriter(ob jFileStream)
    objStreamWriter .WriteLine("thi s text goes into a excel sheet)
    objStreamWriter .WriteLine("")
    objStreamWriter .Close()
    >
    >
    >

    Comment

    • maximz2005

      #3
      Re: question about StreamWriter

      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...@di scussions.micro soft.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\exc el")
      fileName = filePath & "\myfile.xl s"
      >
      objFileStream = New FileStream(file Name, FileMode.OpenOr Create,
      FileAccess.Writ e)
      objStreamWriter = New StreamWriter(ob jFileStream)
      objStreamWriter .WriteLine("thi s text goes into a excel sheet)
      objStreamWriter .WriteLine("")
      objStreamWriter .Close()

      Comment

      Working...