473,322 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

excel unable to use sheet name

i am using c# to parse some excel files to oracle.these files are
created by an automated 3rd party process and we have no control over
the naming convention and the version is excel 4.0 and the sheet names
are all very long (31 characters) when i use oledb to connect and get
the sheet name to select, it returns the filename with a $, and when
used in the select statement it fails because it is too long..i have
tried adox, this also returns the file name as the table name, the only
way i have been successful is in opening the excel file, renaming the
sheet and using the new name..but we don't want to use the excel
object.
I have also tried substr(sheetx,0,31) and adding in the $ but that also
did not work...so how does one use oledb to obtain the default sheet if
the name is too long or get the correct name instead of the file name?
here is the code:

strConnectionString="Provider=Microsoft.Jet.OLEDB. 4.0;Data
Source=c:\\temp\\EXPGRPSTEST_MIO_SBROSGLOBALXUSEMI _Sector_05242004_12M_GRPS.XLS;Extended
Properties=\"Excel 8.0;IMEX=1\"";

System.Data.DataTable dt = null;

OleDbConnection cnCSV =new OleDbConnection (strConnectionString);
cnCSV.Open();

dt = cnCSV.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
sheetx = dt.Rows[0]["TABLE_NAME"].ToString();
OleDbCommand cmdSelect = new OleDbCommand ("SELECT * FROM [" + sheetx
+"]", cnCSV);
OleDbDataAdapter daCSV = new OleDbDataAdapter();
daCSV.SelectCommand = cmdSelect;
DataTable dtCSV = new DataTable ();
daCSV.Fill(dtCSV);
dataGrid1.DataSource = dtCSV;
cnCSV.Close();
cnCSV.Dispose();
daCSV = null;
cnCSV.Close();

any help at all would be appreciated..

thanks

elena

Nov 9 '06 #1
0 1087

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
9
by: Paul | last post by:
Hi all Arggghhh........... The problem.....I want the user to be able to create an excel document and name particular cells in the document where they want the data to be placed and then save...
3
by: Mads Petersen | last post by:
I'm stuck in this code. Hope you can and will help me. I launch it from excel. I have made the following code work, but not as i whant. I need the ranges to be working with something like xlDown....
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
12
by: elziko | last post by:
I'm using late binding (I must) to automate Excel. My code opens Excel after createing and poulating some sheets. My problem is that when the user finally decides to close Excel its process is...
3
by: implicate_order | last post by:
Greetings, I'm new to python and am in the process of writing a script to parse some CSV data, spread it across multiple Excel worksheets and then generate charts. I searched the internet to...
0
by: isis5 | last post by:
i am using c# to parse some excel files to oracle.these files are created by an automated 3rd party process and we have no control over the naming convention and the version is excel 4.0 and the...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
1
by: Sport Girl | last post by:
Hi everybody , i have the task of developing in Perl a script that retrieves data from 3 tables ( bugs, profiles, products) from a MySQL database called bugs and display them in an excel sheet...
2
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.