Export Data to Excel

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

    Export Data to Excel

    I'm trying to export data to an Excel worksheet. I can export the data in
    the cell values perfectly.

    I need the code to change a header and footer for the worksheet, not for the
    columns.

    Is this possible? If so, I really need the code immediately.

    Thank you,
    Elena
  • Armin Zingler

    #2
    Re: Export Data to Excel

    "Elena" <Elena@discussi ons.microsoft.c om> schrieb[color=blue]
    > I'm trying to export data to an Excel worksheet. I can export the
    > data in the cell values perfectly.
    >
    > I need the code to change a header and footer for the worksheet, not
    > for the columns.
    >
    > Is this possible? If so, I really need the code immediately.[/color]


    Have a look at the Excel object model in the Excel documentation. You can
    use Excel via COM interop by setting a reference to the "Microsoft Excel x.y
    object library" on the COM folder on the "add references" dialog.

    See also:




    Armin

    Comment

    • Elena

      #3
      Re: Export Data to Excel

      I'm not sure what you mean. I looked at the article you pointed me to and I
      only see ranges or cells. This is the header/footer outside of the cells and
      on the sheet itself. I'm sorry if I wasn't clear before.

      I already have the library referenced. You need it to be able to export
      anything to Excel.



      "Armin Zingler" wrote:
      [color=blue]
      > "Elena" <Elena@discussi ons.microsoft.c om> schrieb[color=green]
      > > I'm trying to export data to an Excel worksheet. I can export the
      > > data in the cell values perfectly.
      > >
      > > I need the code to change a header and footer for the worksheet, not
      > > for the columns.
      > >
      > > Is this possible? If so, I really need the code immediately.[/color]
      >
      >
      > Have a look at the Excel object model in the Excel documentation. You can
      > use Excel via COM interop by setting a reference to the "Microsoft Excel x.y
      > object library" on the COM folder on the "add references" dialog.
      >
      > See also:
      > http://support.microsoft.com/kb/301982/en-us
      >
      >
      >
      > Armin
      >
      >[/color]

      Comment

      • Armin Zingler

        #4
        Re: Export Data to Excel

        "Elena" <Elena@discussi ons.microsoft.c om> schrieb[color=blue]
        > I'm not sure what you mean. I looked at the article you pointed me
        > to and I only see ranges or cells. This is the header/footer
        > outside of the cells and on the sheet itself. I'm sorry if I wasn't
        > clear before.
        >
        > I already have the library referenced. You need it to be able to
        > export anything to Excel.[/color]


        I didn't know how you exported it to an Excel file and that you already have
        a reference to Excel and know how to use it. Therefore the link. Though,
        have a look at the Excel object model in the Excel documentation. See also
        the appropriate microsoft.publi c.excel.* group.

        Armin

        [color=blue]
        > "Armin Zingler" wrote:
        >[color=green]
        >> "Elena" <Elena@discussi ons.microsoft.c om> schrieb[color=darkred]
        >> > I'm trying to export data to an Excel worksheet. I can export the
        >> > data in the cell values perfectly.
        >> >
        >> > I need the code to change a header and footer for the worksheet, not
        >> > for the columns.
        >> >
        >> > Is this possible? If so, I really need the code immediately.[/color]
        >>
        >>
        >> Have a look at the Excel object model in the Excel documentation. You can
        >> use Excel via COM interop by setting a reference to the "Microsoft Excel
        >> x.y
        >> object library" on the COM folder on the "add references" dialog.
        >>
        >> See also:
        >> http://support.microsoft.com/kb/301982/en-us
        >>[/color][/color]

        Comment

        • Elena

          #5
          Re: Export Data to Excel

          Armin,

          Let me try and be more clear:

          I need the VB.NET code to change the header/footer of an Excel spread sheet.
          I am doing it through a VB application. I can change the ranges/cell values
          using code, but I do not know how to change things outside of the cell
          ranges. I will try and post in an Excel group, but i do not need to change
          it in a worksheet, I need to change it through a VB application. For
          example, I am using this code to change values in certain cells:

          'open excel document
          Dim ThisApplication As Excel.Applicati on
          ThisApplication = New Excel.Applicati on
          ' Start Excel and get Application object.
          ThisApplication = CreateObject("E xcel.Applicatio n")
          ThisApplication .Visible = True
          'connection for package
          Dim Wb As Excel.Workbook =
          ThisApplication .Workbooks.Open ("C:\CDRLReview .xls")
          Dim CDRLWs As Excel.Worksheet = Wb.Worksheets(1 )
          Dim DIDWs As Excel.Worksheet = Wb.Worksheets(2 )

          DIDWs.Range("a2 ").Value = "There is no DID associated with this
          CDRL."
          DIDWs.Range("a2 ").Font.ColorIn dex = 3
          DIDWs.Range("a2 ").Font.Bol d = True

          This code works! Yet, I need to change the Worksheet's header in the same
          fashion.

          I need to know if i can do something like:

          DIDWs.Header.Va lue = <~~ I don' t know what the correct code is, it's just
          an example.


          ~Elena


          "Armin Zingler" wrote:
          [color=blue]
          > "Elena" <Elena@discussi ons.microsoft.c om> schrieb[color=green]
          > > I'm not sure what you mean. I looked at the article you pointed me
          > > to and I only see ranges or cells. This is the header/footer
          > > outside of the cells and on the sheet itself. I'm sorry if I wasn't
          > > clear before.
          > >
          > > I already have the library referenced. You need it to be able to
          > > export anything to Excel.[/color]
          >
          >
          > I didn't know how you exported it to an Excel file and that you already have
          > a reference to Excel and know how to use it. Therefore the link. Though,
          > have a look at the Excel object model in the Excel documentation. See also
          > the appropriate microsoft.publi c.excel.* group.
          >
          > Armin
          >
          >[color=green]
          > > "Armin Zingler" wrote:
          > >[color=darkred]
          > >> "Elena" <Elena@discussi ons.microsoft.c om> schrieb
          > >> > I'm trying to export data to an Excel worksheet. I can export the
          > >> > data in the cell values perfectly.
          > >> >
          > >> > I need the code to change a header and footer for the worksheet, not
          > >> > for the columns.
          > >> >
          > >> > Is this possible? If so, I really need the code immediately.
          > >>
          > >>
          > >> Have a look at the Excel object model in the Excel documentation. You can
          > >> use Excel via COM interop by setting a reference to the "Microsoft Excel
          > >> x.y
          > >> object library" on the COM folder on the "add references" dialog.
          > >>
          > >> See also:
          > >> http://support.microsoft.com/kb/301982/en-us
          > >>[/color][/color]
          >
          >[/color]

          Comment

          • Armin Zingler

            #6
            Re: Export Data to Excel

            "Elena" <Elena@discussi ons.microsoft.c om> schrieb[color=blue]
            > Armin,
            >
            > Let me try and be more clear:
            >
            > I need the VB.NET code to change the header/footer of an Excel
            > spread sheet. I am doing it through a VB application. I can change
            > the ranges/cell values using code, but I do not know how to change
            > things outside of the cell ranges. I will try and post in an Excel
            > group, but i do not need to change it in a worksheet, I need to
            > change it through a VB application. For example, I am using this
            > code to change values in certain cells:[/color]


            I do understand your concerns. I don't have an answer because this is a
            question related to the Excel automation object model (that I don't know
            that good), not a question about VB.Net. You obviously don't have a
            problem in handling VB.Net but handling the Excel object model. In other
            words, if you did it in C#, you would have the same question.


            Armin

            Comment

            • Armin Zingler

              #7
              Re: Export Data to Excel

              "Elena" <Elena@discussi ons.microsoft.c om> schrieb[color=blue]
              > This code works! Yet, I need to change the Worksheet's header in
              > the same fashion.
              >
              > I need to know if i can do something like:
              >
              > DIDWs.Header.Va lue = <~~ I don' t know what the correct code is,
              > it's just an example.[/color]


              Start Excel, start recordin a macro, change the header, stop recording,
              have a look at the generated macro source code. You can apply the same cod
              in VB.Net then.


              Armin

              Comment

              Working...