-
August 18th, 2011, 04:22 AM
#1
Read opened excel problem
The other day I wrote a little program to read Excel files through the Jet engine.
I must admit it is fairly simply to accomplish this but I have already stumbled upon an issue.
The Excel files are being used by other people, the program can read these files that are open so that's correct. The issue is that if you have an Excel file open on your computer and you use the software, it will automatically read the locked files and will try to open these Excel files when the user who is using this closes them.
So the locked files are put in a waiting list to be opened and the user is notified that the file is closed and asks if you want to open it.
When the user that is operates the software closes his Excel before executing, the program works fine without opening the locked files...
Code:
string connectionString = "Provider=Microsoft.Jet.OleDb.4.0; data source=" + path + "; Extended Properties=Excel 8.0;";
string selectString = "SELECT * FROM [Debiteuren$]";
OleDbConnection con = new OleDbConnection(connectionString);
OleDbCommand cmd = new OleDbCommand(selectString, con);
try
{
con.Open();
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = cmd;
DataSet ds = new DataSet();
objAdapter1.Fill(ds);
DataTable dt = ds.Tables[0];
dt = prepareDatatable(dt);
tableToItems(dt, path);
}
catch (Exception ex)
{
}
finally
{
con.Dispose();
}
-
August 18th, 2011, 02:11 PM
#2
Re: Read opened excel problem
-
August 22nd, 2011, 06:08 AM
#3
Re: Read opened excel problem
Does anybody know a workaround or something?
It is not the intention that the user sees these documents.
-
August 22nd, 2011, 04:40 PM
#4
Re: Read opened excel problem
 Originally Posted by tiebird
Does anybody know a workaround or something?
It is not the intention that the user sees these documents.
I'm afraid you aren't explaining your problem well enough.
Can you clearly explain what problem you are having?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|