Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Can't create sheet when importing Excel

I am trying to create an Excel file from my C# program using the Process
function as follows:

string runprog = "c:\\Program Files\\Microsoft Office\\OFFICE12\\Excel.exe";
Process.Start(runprog, excelfile);

When Excel opens up it puts my data from excelfile into a sheet named after
the filename itself. I save the file and then I try to read it later using
the following command:

strSQL = "SELECT * FROM [excelfile]

It says that it doesn't recognize this table or library. So I have 2
questions:

1. Is there a way I can force the imported data to be stored as a sheet
rather than under the filename I am importing?
2. If not, how do I get my SQL command to recognize the table from my excel
file. Right now the only way I can get it to work is to manually import the
data as a sheet and then use the command strSQL = "SELECT * FROM [Sheet1$].

I want to be able to do its automatically thru a program rather than to
manually create the excel file. Does anyone have suggetions on these
questions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Can't create sheet when importing Excel

You don't need to run Excel to read the data from excel!!! All office
products have the same structure. They have documents, tables, pictures. An
excel worksheet is nearly identical to an Access Database (tables).

I would look at Access Open commands to read and write the data. Excel
doesn't understand the SQL but Access will. Create an Access Object then
open/create the Table. Ther arre lots of examples of Reading Workbooks
without opening the workbook. All these techniques use Access commands to
read and write XLS files.

Access is designed so that multiple users can read and write databases.
With Excel if two users open a workbook only the 1st has write priviledges
unless the workbook is shared. Most people don't recommend using Excel in
the shared mode because of conflicts. Access is designed to prevent
conflicts in a shared environment.

"Parrot" wrote:

I am trying to create an Excel file from my C# program using the Process
function as follows:

string runprog = "c:\\Program Files\\Microsoft Office\\OFFICE12\\Excel.exe";
Process.Start(runprog, excelfile);

When Excel opens up it puts my data from excelfile into a sheet named after
the filename itself. I save the file and then I try to read it later using
the following command:

strSQL = "SELECT * FROM [excelfile]

It says that it doesn't recognize this table or library. So I have 2
questions:

1. Is there a way I can force the imported data to be stored as a sheet
rather than under the filename I am importing?
2. If not, how do I get my SQL command to recognize the table from my excel
file. Right now the only way I can get it to work is to manually import the
data as a sheet and then use the command strSQL = "SELECT * FROM [Sheet1$].

I want to be able to do its automatically thru a program rather than to
manually create the excel file. Does anyone have suggetions on these
questions?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Can't create sheet when importing Excel

Joel;
Thanks for your reply as it made me realize I am using the wrong programming
model. I originally wanted to create an Excel database as most users are
familar with Excel and not Access. However, I am writing my system to access
some kind of database so why not use Access since the database will be opaque
to the user anyway. Sometimes you can't see the forest for the trees. I am
still curious as to why I couldn't create a sheet in Excel.


"Joel" wrote:

You don't need to run Excel to read the data from excel!!! All office
products have the same structure. They have documents, tables, pictures. An
excel worksheet is nearly identical to an Access Database (tables).

I would look at Access Open commands to read and write the data. Excel
doesn't understand the SQL but Access will. Create an Access Object then
open/create the Table. Ther arre lots of examples of Reading Workbooks
without opening the workbook. All these techniques use Access commands to
read and write XLS files.

Access is designed so that multiple users can read and write databases.
With Excel if two users open a workbook only the 1st has write priviledges
unless the workbook is shared. Most people don't recommend using Excel in
the shared mode because of conflicts. Access is designed to prevent
conflicts in a shared environment.

"Parrot" wrote:

I am trying to create an Excel file from my C# program using the Process
function as follows:

string runprog = "c:\\Program Files\\Microsoft Office\\OFFICE12\\Excel.exe";
Process.Start(runprog, excelfile);

When Excel opens up it puts my data from excelfile into a sheet named after
the filename itself. I save the file and then I try to read it later using
the following command:

strSQL = "SELECT * FROM [excelfile]

It says that it doesn't recognize this table or library. So I have 2
questions:

1. Is there a way I can force the imported data to be stored as a sheet
rather than under the filename I am importing?
2. If not, how do I get my SQL command to recognize the table from my excel
file. Right now the only way I can get it to work is to manually import the
data as a sheet and then use the command strSQL = "SELECT * FROM [Sheet1$].

I want to be able to do its automatically thru a program rather than to
manually create the excel file. Does anyone have suggetions on these
questions?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Can't create sheet when importing Excel

Because you didn't fetch it with an ADO datasource.
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
Importing into excel spread sheet Annette Excel Discussion (Misc queries) 1 February 27th 09 03:01 PM
Importing excel sheet Viju Gopal Excel Discussion (Misc queries) 0 August 31st 06 05:47 PM
Importing from Excel Sheet Problem workerboy Excel Discussion (Misc queries) 0 August 18th 06 02:44 PM
Is it possible to create a mailing list in excel, not importing d. Claire Bardot New Users to Excel 3 December 29th 05 11:20 PM
help: code for importing xml into excel sheet deepakbadki Excel Programming 0 December 29th 05 08:35 AM


All times are GMT +1. The time now is 01:32 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"