How to load Excel from a string

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

    How to load Excel from a string

    Hi,

    Instead of openning an Excel Worksheet from a file, I set the content of the file into a string (stays in the memory) and I'd like to load it into an Excel Worksheet. Anybody knows how?

    Thanks in advance
  • Y. Sivaram

    #2
    Re: How to load Excel from a string

    Stewart,

    If you have the entire contents in memory you can save it to a temporary
    file and load XML. If you have each individual values then you can use the
    Automation to populate the values in to the Excel worksheet.

    Best Regards,
    Y. Sivaram

    "Li Pang" <LiPang@discuss ions.microsoft. com> wrote in message
    news:E8273835-77BD-4F13-A249-9BE62F3FC03D@mi crosoft.com...[color=blue]
    > Hi,
    >
    > Instead of openning an Excel Worksheet from a file, I set the content of[/color]
    the file into a string (stays in the memory) and I'd like to load it into an
    Excel Worksheet. Anybody knows how?[color=blue]
    >
    > Thanks in advance[/color]


    Comment

    • Li Pang

      #3
      Re: How to load Excel from a string

      Hi Y. Sivaram,

      That is the solution I used currently. In the performance point of view, I don't want to spend the time to save the file and open it after, instead of it I want to open a worksheet directly form the the string.



      "Y. Sivaram" wrote:
      [color=blue]
      > Stewart,
      >
      > If you have the entire contents in memory you can save it to a temporary
      > file and load XML. If you have each individual values then you can use the
      > Automation to populate the values in to the Excel worksheet.
      >
      > Best Regards,
      > Y. Sivaram
      >
      > "Li Pang" <LiPang@discuss ions.microsoft. com> wrote in message
      > news:E8273835-77BD-4F13-A249-9BE62F3FC03D@mi crosoft.com...[color=green]
      > > Hi,
      > >
      > > Instead of openning an Excel Worksheet from a file, I set the content of[/color]
      > the file into a string (stays in the memory) and I'd like to load it into an
      > Excel Worksheet. Anybody knows how?[color=green]
      > >
      > > Thanks in advance[/color]
      >
      >
      >[/color]

      Comment

      • Y. Sivaram

        #4
        Re: How to load Excel from a string

        Li,

        Personally I do not think it is possible as the file contents are raw binary
        and any object can figure it out. If the contents are password protected, it
        will make things even worse.

        But other guys in NG may have different ideas.

        Best Regards,
        Y. Sivaram

        "Li Pang" <LiPang@discuss ions.microsoft. com> wrote in message
        news:92A3DA2D-30CC-4CBD-B4E3-560EBE9C371A@mi crosoft.com...[color=blue]
        > Hi Y. Sivaram,
        >
        > That is the solution I used currently. In the performance point of view, I[/color]
        don't want to spend the time to save the file and open it after, instead of
        it I want to open a worksheet directly form the the string.[color=blue]
        >
        >
        >
        > "Y. Sivaram" wrote:
        >[color=green]
        > > Stewart,
        > >
        > > If you have the entire contents in memory you can save it to a temporary
        > > file and load XML. If you have each individual values then you can use[/color][/color]
        the[color=blue][color=green]
        > > Automation to populate the values in to the Excel worksheet.
        > >
        > > Best Regards,
        > > Y. Sivaram
        > >
        > > "Li Pang" <LiPang@discuss ions.microsoft. com> wrote in message
        > > news:E8273835-77BD-4F13-A249-9BE62F3FC03D@mi crosoft.com...[color=darkred]
        > > > Hi,
        > > >
        > > > Instead of openning an Excel Worksheet from a file, I set the content[/color][/color][/color]
        of[color=blue][color=green]
        > > the file into a string (stays in the memory) and I'd like to load it[/color][/color]
        into an[color=blue][color=green]
        > > Excel Worksheet. Anybody knows how?[color=darkred]
        > > >
        > > > Thanks in advance[/color]
        > >
        > >
        > >[/color][/color]


        Comment

        • Jeff Johnson [MVP: VB]

          #5
          Re: How to load Excel from a string


          "Li Pang" <LiPang@discuss ions.microsoft. com> wrote in message
          news:E8273835-77BD-4F13-A249-9BE62F3FC03D@mi crosoft.com...
          [color=blue]
          > Instead of openning an Excel Worksheet from a file, I set the content of[/color]
          the[color=blue]
          > file into a string (stays in the memory) and I'd like to load it into an[/color]
          Excel[color=blue]
          > Worksheet. Anybody knows how?[/color]

          Excel will only "open" files. Your best bet with the in-memory thing would
          be to create some sort of delimited string, put it on the clipboard, and
          paste it into the workbook. I don't know if Excel is sophisticated enough to
          parse XML this way, but it will surely work with tab-delimited data. You
          could look into formats like BIFF (try www.wotsit.org) if you need more
          detailed information such as formatting.


          Comment

          Working...