Using Databaselayer to get Excel Sheet names? Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Using Databaselayer to get Excel Sheet names?

Post by timg »

Can you use the ODBCDatabaselayer to get the sheetnames from an Excel spreadsheet?

I tried with this code, but it gives me nothing from GetTables()

Code: Select all

	wxFileDialog	fdlog(this, "Open a file","","","*.xls");

	if(fdlog.ShowModal() != wxID_OK) return;
	filename.Clear();
	filename = fdlog.GetPath();
	wxString s = wxT("DRIVER={Microsoft Excel Driver (*.xls)};DSN='';DBQ=") + filename;

	OdbcDatabaseLayer* m_pDatabaseLayer = new OdbcDatabaseLayer();
	if(m_pDatabaseLayer->Open(s))
		m_textCtrl1->AppendText(s);

	wxArrayString	table_names;
	table_names = m_pDatabaseLayer->GetTables();
If I manually supply the sheetname, I can get the field names with this though

Code: Select all

	table_names = m_pDatabaseLayer->GetColumns("Dist$");
Is there something I'm missing to get the sheetnames?
timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg »

A bit more investigation ... GetTables only gets the named ranges in the Workbook.

Is there anyway to get the sheetnames without named ranges? I could do it with wxDB.
timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg »

Doesn't seem anyone has any input and I'm getting tired of the big bold message telling me to mark this thread accepted.
Post Reply