Excel Automation Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
pujari
Experienced Solver
Experienced Solver
Posts: 52
Joined: Fri Sep 07, 2007 11:58 am

Excel Automation

Post by pujari »

Hi Everyone,

I created an excel instance by using wxAutomationObject.I am trying to read data from a particular Sheet(with a specific name) in an existing excel file.
Now How can i get the sheet names???And How can i get the Number of sheets present in an excel?


Thank You in Advance.
timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg »

Can't help at the moment on how to get the names of the sheets, but to get the number of sheets you can use this:

Code: Select all

		appo=xlbook.GetProperty("Sheets.Count");
assuming appo is a wxVariant and xlbook is a wxAutomationObject containing the active workbook.
timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg »

To get the sheet names, you can use this:

Code: Select all

		rng[0] = wxVariant((long) 3);
		res = xlbook.GetObject(xltmp1, "WorkSheets", 1, rng);
		appo = xltmp1.GetProperty("Name");

Just scan through how ever many sheets are returned from the Sheets.Count
Post Reply