Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP 9 Excel Automation - How To Read Sheet Header Info

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
How do I get the value of the cells in an Excel (xlsx) sheet header using automation. I can open and read the rows and columns OK, but not the header info.

Auguy
Sylvania/Toledo Ohio
 
Header info? Surely a header in Excel is just another cell?

Or do you mean the sheet name? If so, it's simply the Name property of the Sheet object. For example:

[tt]? loWorkbook.Sheets(1).Name[/tt]

If that doesn't answer your question, please clarify it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike. No, I can get the sheet name just fine. When I open the xlsx file manually there is a section above row 1 labeled Header that has text in it. Please see attached file. I tried Row 0 with no luck and I can't find any reference as to how to read this info with my google searches. I've some info about turning Headers on/off, but not in automation for reading purposes.

Auguy
Sylvania/Toledo Ohio
 
 http://files.engineering.com/getfile.aspx?folder=7b340718-2669-4921-b119-d05eda107c78&file=Excel_Screen.jpg
Oops, it's the area with "Gasoline" in it.

Auguy
Sylvania/Toledo Ohio
 
Row 1 is the "Seller name", etc.

Auguy
Sylvania/Toledo Ohio
 
I think I found it. At least a start

Code:
oExcel.ActiveSheet.PageSetup.LeftHeader

Auguy
Sylvania/Toledo Ohio
 
I agree with Auguy. Your JPG screen snapshot does not show the Row Numbers.

If you made the Row Numbers visible I am sure that you would find that "Seller Name" and the other 'Header" names are in one of the standard rows.

I doubt that it is Row #1 since "Gasoline" appears in what might be Row #3 or 4 then the 'header' appears down even a few more rows that.

Do a Google search for: excel 2010 make row numbers visible and then make your Row numbers visible.

Good Luck,
JRB-Bldr


 
That's not the issue. I apologize for the bad screen print, I should have included the row numbers. Row 1 is the row with "SELLER NAME". It's the information above row 1 that I need. I found this that will give me the header info I was looking for.
Code:
oExcel.ActiveSheet.PageSetup.LeftHeader
This link explains the header and footer properties and how to read them.

Auguy
Sylvania/Toledo Ohio
 
Sorry Mike (and others), I should have taken more time when i posted the original question and screen shot to make sure it was clear what I needed.

Auguy
Sylvania/Toledo Ohio
 
It's been a long time since I used Excel automation. I forget, do I need to include anything in my deployment package when I use this code?
Code:
oExcel = CreateObject("Excel.Application")

Auguy
Sylvania/Toledo Ohio
 
Thanks once again Mike!

Auguy
Sylvania/Toledo Ohio
 
Auguy,
Did you solve this?
The information in Excel is in the Page Setup area (Headers and footers are not part of the visible sheet, you can only see them at print or print/preview time). Each sheet can have it's own, and up to 3 of them: left, center and right. Same with footer.
The center is most commonly used for text to label the page when it's printed. Right and left frequently have logo or date fields.

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Yes I did thanks. See my post from time "19:36" above. Funny, when I open the file I see the Headers all of the time, but I did not create this file so I'm not sure what they did if this is not the default for displaying the sheets.


Auguy
Sylvania/Toledo Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top