D
defenderjim
Hello All,
Sorry if this is not in the best group.
I am trying to create an XLS file using SQL statements in a C++
program.
All works fine, except that each table I create is on a different
worksheet.
I really need them to be all on one worksheet.
Any suggestions?
Thank you.
-Jim
Code roughly as follows:
CDatabase database;
CString sDriver = "MICROSOFT EXCEL DRIVER (*.XLS)";
CString sExcelFile = "c:\\excelfilename.xls";
sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s
", sDriver, sExcelFile, sExcelFile);
int dbOpen;
try {
// Create the database (i.e. Excel sheet)
dbOpen = database.OpenEx(sSql,CDatabase::noOdbcDialog);
}
catch( ... ) {
// TRACE1("Driver not installed: %s",sDriver);
}
if ( dbOpen ) {
for (short x = 0; x < nTables; x++) {
sSql.Format("CREATE TABLE myTable%d (val1 NUMBER, val2 NUMBER, val3
NUMBER), x);
try {
database.ExecuteSQL(sSql);
}
catch( ... ) {
}
sSql.Format( "INSERT INTO myTable%d ( val1, val2, val3) VALUES (%d,
%d, %d)", x, val1, val2, val3);
try {
database.ExecuteSQL(sSql);
}
catch( ... ) {
}
}
}
Sorry if this is not in the best group.
I am trying to create an XLS file using SQL statements in a C++
program.
All works fine, except that each table I create is on a different
worksheet.
I really need them to be all on one worksheet.
Any suggestions?
Thank you.
-Jim
Code roughly as follows:
CDatabase database;
CString sDriver = "MICROSOFT EXCEL DRIVER (*.XLS)";
CString sExcelFile = "c:\\excelfilename.xls";
sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s
", sDriver, sExcelFile, sExcelFile);
int dbOpen;
try {
// Create the database (i.e. Excel sheet)
dbOpen = database.OpenEx(sSql,CDatabase::noOdbcDialog);
}
catch( ... ) {
// TRACE1("Driver not installed: %s",sDriver);
}
if ( dbOpen ) {
for (short x = 0; x < nTables; x++) {
sSql.Format("CREATE TABLE myTable%d (val1 NUMBER, val2 NUMBER, val3
NUMBER), x);
try {
database.ExecuteSQL(sSql);
}
catch( ... ) {
}
sSql.Format( "INSERT INTO myTable%d ( val1, val2, val3) VALUES (%d,
%d, %d)", x, val1, val2, val3);
try {
database.ExecuteSQL(sSql);
}
catch( ... ) {
}
}
}