Export to excel

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

    Export to excel

    Hi and TIA! I have an export procedure that exports my data from my
    datagrids to excel. The problem is that I lose leading zero's cause excel
    removes them and doesn't treat them as text. Is it possible to design an
    excel template file, place it in my shared network folder and have the
    procedure write data to the template file? I've thought of reading the
    recordset line by line, field by field and concatenating an apostrophe at
    the beginning of each field, but this seems a little overboard and some of
    the recordsets are quit large. I'm open for any advice or if you could
    point me in the correct direction I would appreciate it. Thanks!

  • =?Utf-8?B?SnVsaWEgQg==?=

    #2
    RE: Export to excel

    Hi, I had this problem also. This is an asp.net 1.1 solution - I don't know
    what version you're working in but I'm sure there'll be something similar in
    all versions. You can add a text attribute to your datagrid after it's
    databound which ensures Excel treats the data as text and doesn't remove
    leading zeros:

    For rowPos As Integer = 0 To DataGrid.Items. Count - 1
    For colPos As Integer = 0 To
    DataGrid.Items( rowPos).Cells.C ount - 1

    DataGrid.Items( rowPos).Cells(c olPos).Attribut es.Add("class", "text")
    Next
    Next

    Hope this helps.
    Julia

    "Reggie" wrote:
    Hi and TIA! I have an export procedure that exports my data from my
    datagrids to excel. The problem is that I lose leading zero's cause excel
    removes them and doesn't treat them as text. Is it possible to design an
    excel template file, place it in my shared network folder and have the
    procedure write data to the template file? I've thought of reading the
    recordset line by line, field by field and concatenating an apostrophe at
    the beginning of each field, but this seems a little overboard and some of
    the recordsets are quit large. I'm open for any advice or if you could
    point me in the correct direction I would appreciate it. Thanks!
    >
    >

    Comment

    • Reggie

      #3
      Re: Export to excel

      Julia, Thanks but it still removes the leading zero's when I export the
      grid. I'll keep looking and if I come up with something will post back.
      Thanks!
      "Julia B" <JuliaB@discuss ions.microsoft. comwrote in message
      news:98DF4D47-6D29-42D4-87E5-C8A9335B236C@mi crosoft.com...
      Hi, I had this problem also. This is an asp.net 1.1 solution - I don't
      know
      what version you're working in but I'm sure there'll be something similar
      in
      all versions. You can add a text attribute to your datagrid after it's
      databound which ensures Excel treats the data as text and doesn't remove
      leading zeros:
      >
      For rowPos As Integer = 0 To DataGrid.Items. Count - 1
      For colPos As Integer = 0 To
      DataGrid.Items( rowPos).Cells.C ount - 1
      >
      DataGrid.Items( rowPos).Cells(c olPos).Attribut es.Add("class", "text")
      Next
      Next
      >
      Hope this helps.
      Julia
      >
      "Reggie" wrote:
      >
      >Hi and TIA! I have an export procedure that exports my data from my
      >datagrids to excel. The problem is that I lose leading zero's cause
      >excel
      >removes them and doesn't treat them as text. Is it possible to design an
      >excel template file, place it in my shared network folder and have the
      >procedure write data to the template file? I've thought of reading the
      >recordset line by line, field by field and concatenating an apostrophe at
      >the beginning of each field, but this seems a little overboard and some
      >of
      >the recordsets are quit large. I'm open for any advice or if you could
      >point me in the correct direction I would appreciate it. Thanks!
      >>
      >>

      Comment

      • Mark Rae [MVP]

        #4
        Re: Export to excel

        "Reggie" <chief123101@ya hoo.comwrote in message
        news:%23U%23rDy HJJHA.1556@TK2M SFTNGP03.phx.gb l...
        >>Hi and TIA! I have an export procedure that exports my data from my
        >>DataGrids to Excel. The problem is that I lose leading zeroes because
        >>Excel removes them and doesn't treat them as text. Is it possible to
        >>design
        >>
        >Hi, I had this problem also. This is an ASP.NET 1.1 solution - I don't
        >know what version you're working in but I'm sure there'll be something
        >similar in all versions. You can add a text attribute to your DataGrid
        >after it's
        >databound which ensures Excel treats the data as text and doesn't remove
        >leading zeros:
        >
        Julia, Thanks but it still removes the leading zeroes when I export the
        grid. I'll keep looking and if I come up with something will post back.
        Have you tried prefixing the data with an apostrophe...?

        E.g. '000123


        --
        Mark Rae
        ASP.NET MVP


        Comment

        • sloan

          #5
          Re: Export to excel

          I was going to say about the same thing.

          I ended up putting an "@" in front of the value.

          ' would be even more abrupt.



          "Mark Rae [MVP]" <mark@markNOSPA Mrae.netwrote in message
          news:ezoQZ2HJJH A.4600@TK2MSFTN GP06.phx.gbl...
          "Reggie" <chief123101@ya hoo.comwrote in message
          news:%23U%23rDy HJJHA.1556@TK2M SFTNGP03.phx.gb l...
          >
          >>>Hi and TIA! I have an export procedure that exports my data from my
          >>>DataGrids to Excel. The problem is that I lose leading zeroes because
          >>>Excel removes them and doesn't treat them as text. Is it possible to
          >>>design
          >>>
          >>Hi, I had this problem also. This is an ASP.NET 1.1 solution - I don't
          >>know what version you're working in but I'm sure there'll be something
          >>similar in all versions. You can add a text attribute to your DataGrid
          >>after it's
          >>databound which ensures Excel treats the data as text and doesn't remove
          >>leading zeros:
          >>
          >Julia, Thanks but it still removes the leading zeroes when I export the
          >grid. I'll keep looking and if I come up with something will post back.
          >
          Have you tried prefixing the data with an apostrophe...?
          >
          E.g. '000123
          >
          >
          --
          Mark Rae
          ASP.NET MVP
          http://www.markrae.net

          Comment

          • Reggie

            #6
            Re: Export to excel

            Mark, That's my next step. Like I said some of these recordsets are quit
            large, so was thinking this may be a little slow. I'll try and let u know.
            Thanks!

            Reggie

            "Mark Rae [MVP]" <mark@markNOSPA Mrae.netwrote in message
            news:ezoQZ2HJJH A.4600@TK2MSFTN GP06.phx.gbl...
            "Reggie" <chief123101@ya hoo.comwrote in message
            news:%23U%23rDy HJJHA.1556@TK2M SFTNGP03.phx.gb l...
            >
            >>>Hi and TIA! I have an export procedure that exports my data from my
            >>>DataGrids to Excel. The problem is that I lose leading zeroes because
            >>>Excel removes them and doesn't treat them as text. Is it possible to
            >>>design
            >>>
            >>Hi, I had this problem also. This is an ASP.NET 1.1 solution - I don't
            >>know what version you're working in but I'm sure there'll be something
            >>similar in all versions. You can add a text attribute to your DataGrid
            >>after it's
            >>databound which ensures Excel treats the data as text and doesn't remove
            >>leading zeros:
            >>
            >Julia, Thanks but it still removes the leading zeroes when I export the
            >grid. I'll keep looking and if I come up with something will post back.
            >
            Have you tried prefixing the data with an apostrophe...?
            >
            E.g. '000123
            >
            >
            --
            Mark Rae
            ASP.NET MVP
            http://www.markrae.net

            Comment

            Working...