|
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.
|
|
|
|
|
no, I did not solve a problem (Office2K). You might check for the very first char (') in the cell. It is invisible but will convert cell to the text.
I did switch to Excel OLE Application wrapper.
Gennady
|
|
|
|
|
Hi,as I need to do a project to convert MS excel file from client to HTML, i.e, update a web page by just uploaading a excel file.(it is done for the non-programmer). Can this source help my project and can anyone give me some comment!!
thanks.
kee_kee
|
|
|
|
|
|
I have written a similar example in plain C (no C++, MFC, etc).
The example supports writing to and reading from Excel workbooks using the ODBC Excel Driver.
However, there is a major issue with the Excel ODBC Driver and mixed data types.
As excel columns do not have 'types', the odbc driver scans the first 8 rows to determine the data type of a column. Values that are not of the determined type will return NULL. The 8 rows value can be changed by changing the TypeGuessRows value in the registry.
So, if a column contains mixed data types you will lose data that is not of the determined type. The OLEDB driver for Excel has the IMEX=1 workaround for this problem but the ODBC driver does not seem to support this.
Therefore, if you want to use the ODBC driver you must make sure each column has only one data type or be prepared to lose some of your data when you import it with ODBC. The easiest way of forcing a column to contain only one data type is to set it to text:
To force numbers to be entered as text right click a column->Click Format Cells->Set category to text.
However, this will not change existing entries.
Some more information on this can be found at MS KB Article 257819[^] under 'A Caution about Mixed Data Types' (halfway down).
If you need the ability to retrieve mixed data types you may have to use ADO with the JET OLEDB provider and IMEX=1 extended property.
The code can be found in zip form on this page under the name OdbcExcl:
ODBC Excel Sample in Plain C[^]
|
|
|
|
|
Hi,
I have tried compiling the code ( NO Changes! ) on MS Visual Studio 6 on Win 2k SP 3.
It dosent recognize certain data types. any reason why ?
Ex: SQLLEN is not even in the header files SQLEXT.H or SQL.H or SQLTYPE.H
any idea?
Thankx
|
|
|
|