|
Hi all
How i can read xls file with out using standard COM library of Excel(Microsoft Excel x.0 Object Library), because it work very slow. I try to export data from XLS file to XML file first and after
read this XML file, but unfotunately Excel 9.0 library has not this functionality.
Any idea please.
-- modified at 9:22 Thursday 29th November, 2007
|
|
|
|
|
Dear Friend,
Hi.
string strFileName = "fileName.xls";
System.Data.OleDb.OleDbConnection excelConn = new System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source= '" + strFileName + "'; " + " extended properties=excel 8.0;");
string strsql = "Select * from [Sheet1$]";
System.Data.OleDb.OleDbDataAdapter excelDataAdap = new System.Data.OleDb.OleDbDataAdapter(strsql, excelConn);
dsExcel = new DataSet();
if (excelConn.State == ConnectionState.Closed)
{
excelConn.Open();
}
//Select the values from Excel
excelDataAdap.Fill(dsExcel);
GridView1.DataSource = dsExcel;
GridView1.DataBind();
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(strsql, excelConn);
System.Data.OleDb.OleDbDataReader dr = cmd.ExecuteReader();
string sqlConnectionString = "Data Source=srvr;Initial Catalog=db;User Id=usr;Password=pwd";
// Bulk Copy to SQL Server
System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(sqlConnectionString);
bulkCopy.DestinationTableName = "ExcelData";
bulkCopy.WriteToServer(dr);
I hope this will helps u.....
"Good Thing Goes With Good People..."
|
|
|
|
|
I have a P-Invoek function to call with a pointer to pointer Parameter wich should return
an Array.
The function call is this:
public static unsafe extern uint lhs_asrGrmGetWords(LHS_HSAFE hGrm, ASR_WORDINFO** ppWordInfo, void* pulNbrOfWords);
The problem is in the second parameter.
[StructLayout(LayoutKind.Sequential)]
unsafe public struct ASR_WORDINFO
{
public uint ulID;
public void* szWord;
}
This way I can make a parameter with a double pointer for one item of the array:
NbrOfWords = 0;
void* pulNbrOfWords = &NbrOfWords;
ASR_WORDINFO pointerValue;
ASR_WORDINFO* pointer1 = &pointerValue;
ASR_WORDINFO** pointer2 = &pointer1;
result = VoConPInvoke.lhs_asrGrmGetWords(hGrm, pointer2, pulNbrOfWords);
pointerValue holds now one element of the array and NbrOfWords the value of the third parameter.
For a single pointer for an Array it works like this:
ASR_WORDINFO[] pointerValue = new VoConStruct.ASR_WORDINFO[10];
fixed (VoConStruct.ASR_WORDINFO* pointer1 = pointerValue)
{
result = lhs_asrGrmAnotherWithOnePointer(recogObjects.hGrm, pointer1, pulNbrOfWords);
}
pointerValue holds the array and NbrOfWords the value of the third parameter (= the Length of the Array).
But how do I make it for the whole array???
This won't compile:
NbrOfWords = 0;
void* pulNbrOfWords = &NbrOfWords;
ASR_WORDINFO[] pointerValue; // with the []
ASR_WORDINFO* pointer1 = &pointerValue;
ASR_WORDINFO** pointer2 = &pointer1;
result = VoConPInvoke.lhs_asrGrmGetWords(recogObjects.hGrm, pointer2, pulNbrOfWords);
How to make this compile???
G.M. van Heuckelum
mailto: g.van.heuckelum@agripartner.nl
Software Engineer
|
|
|
|
|
maybe this[^] helps
greets
m@u
|
|
|
|
|
this[^] is in c++ Handle to Object on Managed Heap.
In C# ^]is something different, so I can not use this[^] in my C# code.
|
|
|
|
|
Boy I really needed a laugh, thank you.
|
|
|
|
|
I have a checked list box that has about 20 items in the list. At a certain time I need to lock the control from the user so no more items can be checked or unchecked. If I set the control's Enabled property to false, the user cannot check any items but they are also prevented from scrolling down the list to see what items are checked.
How do I disable checking but allow the user to still scroll through the list? Thanks!
|
|
|
|
|
You may want to handle ItemCheck event and write some code to decide if item's CheckState value should be changed or not.
|
|
|
|
|
I'm trying to do the following but it does not compile?
<code>struct ProxyHolder<TInterface> where TInterface : class
{
public ProxyHolder(ClientBase<TInterface> client, object clientLock)
{
}
}
Dictionary<Type, ProxyHolder<TInterface>> proxies;</code>
This fails on the TInterface in the Dictionary declaration.
Is there any way of achieving this? For ProxyHolder I can pass in Type instead of TInterface, which would compile but then this code would fail
<code>proxies.Add(typeof(JobManagerClient), new ProxyHolder<IJobManager>(jobManager, jobManagerLock));</code>
with:
Argument '2': cannot convert from '<IJobManager>' to 'ProxyHolder<System.Type>'
Kevin
|
|
|
|
|
Kevin McFarlane wrote: This fails on the TInterface in the Dictionary declaration.
Thats because TInterface is not declared. You will need to specify a type, or move that declaration into the ProxyHolder struct (if possible) where TInterface is defined.
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
So TInterface has to be a closed constructed type right? That's the problem, I don't know in advance what type it should be.
Kevin
|
|
|
|
|
I'm a bit confused about your syntax here. Is IJobManager an interface (I certainly hope so from the name)? You should be able to do this with proxies.Add(typeof(JobManagerClient), new ProxyHolder(jobManager, jobManagerLock)); The compiler should be able to determine the type of TInterface from the TInterface parameter in the ProxyHolder.
-- modified at 8:15 Thursday 29th November, 2007
Scrap the struck out statement. It's gibberish. Thanks to leppie for making me look at it again.
|
|
|
|
|
Pete O`Hanlon wrote: The compiler should be able to determine the type of TInterface from the TInterface parameter in the ProxyHolder.
Definately not the C# 2.0 compiler
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
You're right of course. I don't know what I was thinking of here. I've just relooked at his original post, and the generics are a complete mess. He needs to simplify it a lot.
|
|
|
|
|
Pete O`Hanlon wrote: He needs to simplify it a lot.
How?
Kevin
|
|
|
|
|
Wouldn't this
Dictionary<Type, ProxyHolder<TInterface>> proxies;
need to be this
Dictionary<Type, ProxyHolder<IJobManager>> proxies ;
?
|
|
|
|
|
The problem is I don't know in advance what ProxyHolder is going to hold. I fear that I cannot solve my problem in the way I want. Probably needs a rethink. Basically I'm trying to reduce a whole bunch of if-else tests to a single lookup table.
Kevin
|
|
|
|
|
|
Yes, I'd more-or-less concluded that. Plus, I've now managed to simplify my problem down to a single if-else decision point. That's OK for now.
Kevin
|
|
|
|
|
VS2005
I've added some settings to a program I'm writing, and set the scope to "User", but I can't get it to write new values for those settings. I'm calling Properties.Settings.Default.Save() , but nothing appears to be happening. Since the scope is set to user, I expect to see a user.config file in documents and settings under my user name, but I don't see anything at all.
What could I be doing wrong?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: What could I be doing wrong?
User settings gets saved under the user folder (god knows where), and gets picked up from there if different from the app.config. Note app.config is never changed.
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
|
I'll look there tonite.
However, I don't think it's working because I can't appear to retrieve data I "save"d.
Why does everything in .net have to be so convoluted?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
After a quick look on my system I find the settings files in the following location
C:\Documents and Settings\username\Local Settings\Application Data\companyname\applicationame.exe_Url_4jxa32l1jl5ig3yszvzaymm2fpoq5w4k\1.0.0.0\user.config
where
companyname is that set in the company field of the assembly information
You may end up with several versions of the config file in which case they will have different _Url_4jxa32l1j.... tagged on the end of the exe name.
Alan.
|
|
|
|
|
Those pesky autochanging version numbers always cause me problems.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|