Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Importing data from the active sheet w/ c#

Hi,
i'm using this code to import data from an EXCEL file:

oleConn = new OleDbConnection(strConn);
oleConn.Open();

dtSchema = oleConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables , null);
DataRow fRow = dtSchema.Rows[0];
TheSheet = fRow["TABLE_NAME"].ToString();
TheSheet = TheSheet.Substring(0, TheSheet.Length - 1);
oleConn.Close();

if (!TheSheet.EndsWith("$")) TheSheet += "$";
OleDbDataAdapter myAdapter = new OleDbDataAdapter("SELECT * FROM [" +
TheSheet+ "]", strConn);
myAdapter.Fill(ds);


The problem occurs when the first sheet (DataRow fRow = dtSchema.Rows[0];)
is not the active one.

So my question is ... in the code above, how can i get the actie sheet
instead of the first one?
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird Problem while Importing Data into another sheet Sundar Excel Discussion (Misc queries) 0 July 2nd 08 04:50 PM
Importing Data from Multible Ranges in Excel Sheet hadoka Excel Discussion (Misc queries) 1 November 19th 06 02:56 AM
importing data from other sheet koldtooth Excel Discussion (Misc queries) 3 June 14th 06 03:46 PM
importing data into sheet with subtotals LindaB@work Excel Discussion (Misc queries) 0 April 7th 06 03:43 PM
Copy from active sheet and paste into new sheet using info from cell in active Ingve Excel Programming 3 January 23rd 06 09:57 PM


All times are GMT +1. The time now is 05:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"