|
Have a large file that exceeds the number of rows in EXCEL and would like to write the files to ACCESS instead. Any ideas?
|
|
|
|
|
Hi,
the executable runs fine but when I compile the project and try to run it I get the following error message :
"Database error : The Microsoft Jet database engine could not find the object "demo_table". Make sure the object exists and that you spell its name ant the path name correctly."
What could it be? My version of Office?
Thanks,
Francis
|
|
|
|
|
just include ReadExcel.xls in the working exe folder
|
|
|
|
|
I want to read data from excel sheet. I make two text box in my form name txtBEG and txtEND. I want to retrieve all dates between the begining date and end date whatever the user types in that text boxes. The connection is showing well. but I am facing lot of problem in it. I dont know why?
Everytime its showing an error messge "DataType mismatch" and the cursor is going to the data reader. can any one help me please in this regard by correcting the code.
***In my excel sheet i created the date field in date format like this 3/14/01(4th item in Type list box) and the excel is read only.
***I think the values are not converting in datetime value which the excel generates. Help me on this issue and correct the code please.....
My Code is Given below
------------------------
private void cmdTransferData_Click(object sender, EventArgs e)
//====================================================
{
Read_Excel(txtBEG.Text, txtEND.Text)
}
private void Read_Excel(string begDate_In,string endDate_In)
//===============================================
{
string strConn = "";
string pstrPassword = "";
string pstrFileName = "";
pstrFileName= "C:/TransRef.xls";
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Jet OLEDB:Database Password=" + pstrPassword +
"; " + "Data Source= " + pstrFileName + "; " +
"Extended Properties=Excel 8.0;"; //+
DateTimeFormatInfo dtF = new CultureInfo("en-US", +
false).DateTimeFormat;
string pstrFROM, pstrFIELDS, pstrWHERE;
string pstrSQL = ""; Boolean blnOrderBy = false;
pstrFROM = "FROM [TRANSREF$] ";
pstrFIELDS = "TD ";
pstrWHERE = "WHERE TD >= '" + (DateTime.Parse(begDate_In)).ToString("d", dtF) + "' and TD <= '" + DateTime.Parse(endDate_In).ToString("d", dtF) + "' ";
pstrSQL = "SELECT " + pstrFIELDS + pstrFROM +
pstrWHERE;
OleDbCommand myCommand = new OleDbCommand(pstrSQL);
OleDbConnection myConnection = new OleDbConnection
(strConn);
myConnection.Open();
myCommand.Connection = myConnection;
OleDbDataReader myReader = myCommand.ExecuteReader();
int pCountRec = 0;
string pRowVal = "";
while (myReader.Read())
{
pCountRec = pCountRec + 1;
pRowVal = myReader["TD"].ToString();
MessageBox.Show(pRowVal);
}
myConnection.Close();
}
|
|
|
|
|
I ha ve more than three rows , this program reads only 3 rows.
|
|
|
|
|
Yes, I Have the same problem , please help us.
Excel Formating problem .?!. or C++ Code Problem..?!
|
|
|
|
|
This program reads only records that were written using program from article "http://www.codeproject.com/KB/database/excel_odbc_write.aspx". If you make any changes of content it doesn't change written data.
|
|
|
|
|
hi,
i wrote a project that takes data from database and saves it as an excel document. i tried to run the project on different computer but without giving any error, it stops running. i copied all the dll files and i have the same framework that i compiled the project.
is there any way to deploy an office 2000 project?
thanks for your concern.
|
|
|
|
|
You mention in your article, that you canot read from az excel file without some formatting.
I found this atrticle wich shows how to do this without formatting.
The link to this article is:
http://www.idude.net/excel/articles/using_excel_file_datasources.asp
The info from the article:
<<
There are a number of ways you can reference a table (or range) in an Excel workbook:
* Workbook Name
Use the Workbook Name followed by a dollar sign (for example, [Sheet1$] or [My Workbook$]).
A Workbook table that is referenced in this manner consists of the entire used range of the Workbook.
"Select [column_names] from [Sheet1$]"
* Cell Range
Use the Workbook Name followed by a dollar sign with cell range appended to it! Don't forget to use the colon : between the starting and ending cell positions!
"Select [column_names] from [Sheet1$A1:B10]"
* Named Range
This is a range of cells with a defined name
"Select [column_names] from [Defined Name Range]"
>>
For more info, read the entire article
|
|
|
|
|
Hi Everyone,
I've been a member for sometime now and have been reading a few things on this forum. This is the first time that I'm posting a request. Hope you all gurus will respond.
I want to read/write MS excel sheets on Unix/solaris platform using C++.
I did go through the article posted by Alexander Mikula on how to use ODBC and read excel sheets using CRecordset.
But I'm not sure how to use ODBC connection in Unix/solaris.
Please tell me ways to do it unix using C++.
Thanks.
Tanz.
|
|
|
|
|
Unix?
If Microsoft wanted to make their formats available (easily) to everyone no matter what platform they where on, they would have simply made it the easy way... That is, suppling an easy cross platform c/c++-api that you could link into your project.
I think its pretty obvious (with the excel-driver approach) that they don't want you to even consider using anything else than windows. (they also want you to pony up the dough for Microsoft(c) Office[tm])
Sorry for the one year late reply, I'm just very frustated that this sort of crap is allowed.
|
|
|
|
|
I want to use SQL SELECT statement: Select * form demo_table where field_2 = ’†‘; but is doesn't support chinese
|
|
|
|
|
Hello,
i try, but it don't works.
I get an Error:
"Database error: The Micosoft Jet-Databasemodul couldt not find the 'demo_table' Object."
The App open the File correctly, but the Worksheet fails.
WHY ???
MfG
BK
|
|
|
|
|
I need a program which can read more than 2 columns, but when i try adding to: sSq1= "SELECT Field1, Field2 FROM [Sheet1$]", it can only take Field1 and Field2. When I try adding a thrid one in... it just won't work. Can someone please help me with this?
hellie
|
|
|
|
|
I found out a method of how to use more than one column in the program. I am not sure if it is the official way to do it, but it works on my program so... here it is:
sSq1= "SELECT * FROM [Sheet1$]"
recset.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly);
recset.GetFieldValue("Field1",1);
recset.GetFieldValue("Field2",2);
recset.GetFieldValue("Field3",3);
hellie
|
|
|
|
|
This program reads only data that were written with program from article "http://www.codeproject.com/KB/database/excel_odbc_write.aspx"
The table name for reading must correspond the table name in that programm. You can't change neighter name of written table nor any data from editor - only by writing program.
|
|
|
|
|
Alexander:
I tried to run your demo readExcel on my PC and got an error message
" Database error: Specified driver could not be loaded due to system error 182{Microsoft Excel Driver [*.xls}} "
I don't know what that means, could you help?
Tina
|
|
|
|
|
When I read the FAQ's on these articles, the biggest problems seems to be the tables names. How can I know the table (sheetname) is demo_table?
To provide a list of all tables/sheet in an excelfile, simply use the class CTable from the Microsoft DBFetch sample. (this sample project is on your visual C++ CD).
With this table you can generate a list of all the tables in an excelfile.
|
|
|
|
|
I tried using the CTable class, but the class did not return any table names.
I did not receive any error messages. The program returned EOF(), when I tried to iterate through the tables (my spreadsheet has data).
Curiously, I tried "Sheet1" for the table name (which is the name at the bottom of the spreadsheet) and that did not work either.
Jacques
|
|
|
|
|
i had the same problem.
Solution:
Rename the File !
I dont know why, but it works ...
|
|
|
|
|
This program reads only data that were written with program from article "http://www.codeproject.com/KB/database/excel_odbc_write.aspx"
The table name for reading must correspond the table name in that programm. You can't change neighter name of written table nor any data from editor - only by writing program.
|
|
|
|
|
Hi,
I want to change the font style i.e. headers with bold and change some colors in the data tables (columns or rows) depending on the value. I dont know whether this can be done or not. Please guide me as i have not used excel before. I have to use MFC and i have excel 2003. Looking forward to a response. Thanks a lot in advance.
Regards,
Himanshu
|
|
|
|
|
Thanks, Alexander, for your article.
I'm in a position to reading to write from a sheet excell, my problem is in deleting from excel.
I think that i'm not able open correctly CDataBase m_database
sql.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",m_driver, m_filestr );
if (m_database.Open(NULL, false, false, sql)){
m_rc = new CRecordset ( &m_database ) ;
if (m_database.CanUpdate( )) MessageBox(NULL,"è update","errore",MB_OK);
//*********** always is not Updateble
sql.Format ( "SELECT * FROM Personale" ) ;
m_database.ExecuteSQL ( sql ) ;
m_rc -> Open ( CRecordset::dynaset,sql,CRecordset::none ) ;
int count = 0 ;
while ( m_rc -> IsEOF( ) != 1 )
{
m_rc->GetFieldValue ( "Cognome", str ) ;
if (!str.Compare( CognomeL ) ) {
m_rc->Delete();
if (!m_rc->IsDeleted( ) ) MessageBox(NULL,"è cancellato","errore",MB_OK);
}
m_rc -> MoveNext( ) ;
count++ ;
}
} else MessageBox(NULL,"non aperto","errore",MB_OK);
m_rc -> Close( ) ;
delete m_rc;
m_database.Close( ) ;
|
|
|
|
|
Thanks, Alexander, for your article.
I'm using your sample ReadExcel.exe:
http://adam.stup.ac.ru/Developer/ArticleDetail.aspx?ar=1053&l=n&mi=97&mic=139 (the same ODBC excel reader) to read ReadExcel.xls. And it works fine. But if I change the very first item "aaa" to number (ex. 1) it dissapears from output!
Looks like ODBC RecordSet cell type depends on cell type from previous row (hidden in header row?).
Can not figure it out how to "reset" RecordSet buffer before reading next row.
Do you have any suggestions to fix this problem? I want read all data as a text only.
Gennady
|
|
|
|
|
Have you solved this problem? I'm think I'm having a similar problem, except I'm doing number and not text. If the first line after the column title is missing data (which sometimes is the case because not all fields are required), then the rest of the column can not be read in.
Anyone have a solution to this? Thanks in advance.
|
|
|
|