Export Data to Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Elena said:
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



Armin
 
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.
 
Elena said:
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.


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.public.excel.* group.

Armin
 
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.Application
ThisApplication = New Excel.Application
' Start Excel and get Application object.
ThisApplication = CreateObject("Excel.Application")
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.ColorIndex = 3
DIDWs.Range("a2").Font.Bold = 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.Value = <~~ I don' t know what the correct code is, it's just
an example.


~Elena
 
Elena said:
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:


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
 
Elena said:
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.Value = <~~ I don' t know what the correct code is,
it's just an example.


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
 
Back
Top