jtran007
asked on
Excel cell format
Hi Expert,
I have problem to read one column whose format is text. On the spreadsheet I see
all values, but when I read it by using oledb some line of the same column returned
null. Then I check its format. it is text and possibly has 'apostrophy' infront. Then I add
" ' " in front of the cell, then I can read it.
How can I use excel macro to check if the cells in this column named has " ' " if not ,
my macro will add " '". I am new to macro excel.
Could you please help me out?
Thx,'
JT
I have problem to read one column whose format is text. On the spreadsheet I see
all values, but when I read it by using oledb some line of the same column returned
null. Then I check its format. it is text and possibly has 'apostrophy' infront. Then I add
" ' " in front of the cell, then I can read it.
How can I use excel macro to check if the cells in this column named has " ' " if not ,
my macro will add " '". I am new to macro excel.
Could you please help me out?
Thx,'
JT
OleDbCommand cmd3 = new OleDbCommand("select * from [" + txtSheetName.Text + "$]", con);
using (rd = cmd3.ExecuteReader())
{
int index = 0;
while (rd.Read())
{
index++;
if (index < DataRowIndex - 1)
{
continue;
}
else if (index == int.Parse(txtEndedData.Text.ToString()) - 1)
{
goto closing;
}
string countryId = null;
if (countryName != null)
{
countryId = valid(rd, CountryNameIndex);
//countryId = rd[CountryNameIndex].ToString();
}
string Destination = null;
Destination = valid(rd, DestIndex);
if (Destination.Equals("")) continue;
string countryCode = null;
if (DNCountry != null)
countryCode = valid(rd, DNCountryIndex);
//countryCode = rd[DNCountryIndex].ToString();
string cityCode = null;
cityCode = valid(rd, DNAreaIndex);
string Rate = null;
sheetname-err.xls
ASKER
Hi Expert,
After adding IMEX=1, I receive this error message "could not find installable ISAM".
Do you what it means?
Thx,
JT
After adding IMEX=1, I receive this error message "could not find installable ISAM".
Do you what it means?
Thx,
JT
That error just means that you have the connection string incorrect. That article pointed to connectionstrings.com, which has the IMEX=1 in the Extended Properties:
http://www.connectionstrings.com/excel
Provider=Microsoft.Jet.OLE DB.4.0;Dat a Source=C:\MyExcel.xls;Exte nded Properties="Excel 8.0;HDR=Yes;IMEX=1";
http://www.connectionstrings.com/excel
Provider=Microsoft.Jet.OLE
ASKER
Hi expert,
I checked everything , it seems ok but i still have the error.
Also is there limit of charaters in the Excel cell, if yes, how can I increase it since
some of my cell contains more than 255 characters.
Thx,
JT
I checked everything , it seems ok but i still have the error.
Also is there limit of charaters in the Excel cell, if yes, how can I increase it since
some of my cell contains more than 255 characters.
Thx,
JT
Under [Worksheet and workbook specifications] you can see Excel 2003 cell limit (255 chars)
http://office.microsoft.com/en-us/excel/HP051992911033.aspx
Here's the same thing but to Office 2007 (same limitation)
http://office.microsoft.com/en-us/excel/HP100738491033.aspx
So this is a limitation of Excel. Another link:
http://support.microsoft.com/kb/213841
ASKER
Hi expert,
AlexCode: thanks.
I use "using Microsoft.Office.Tools.Exc el; and using System.Data.OleDb;" to access Excel, but I still have
""could not find installable ISAM" . Do I miss something?
And my connection string is:
"Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=C:\\Documents and Settings\\xuan\\My Documents\\ex\\codeerr.xls ;Extended Properties=Excel 8.0; HDR=YES; IMEX=1"
Thx,
JT
AlexCode: thanks.
I use "using Microsoft.Office.Tools.Exc
""could not find installable ISAM" . Do I miss something?
And my connection string is:
"Provider=Microsoft.Jet.OL
Thx,
JT
Sorry mate, I'm finding it difficult to help you on that one.
Didn't the microsoft support link I gave you help in any way?
Didn't the microsoft support link I gave you help in any way?
ASKER
Hi Expert,
The support site that you told me did not help since whatever they recommend I did.
However I still have this error "could not find installable ISAM".
Thanks,
JT
The support site that you told me did not help since whatever they recommend I did.
However I still have this error "could not find installable ISAM".
Thanks,
JT
What does your connection string look like?
ASKER
Hi expert,
Please read my attached connection string in previous conversation.
And my connection string is:
"Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=C:\\Documents and Settings\\xuan\\My Documents\\ex\\codeerr.xls ;Extended Properties=Excel 8.0; HDR=YES; IMEX=1"
Thx,
JT
Please read my attached connection string in previous conversation.
And my connection string is:
"Provider=Microsoft.Jet.OL
Thx,
JT
I'm not sure if they're required but I notice you're missing some quotes in that string. Try some double quote around that last part
Extended Properties=""Excel 8.0; HDR=YES; IMEX=1"""
Extended Properties=""Excel 8.0; HDR=YES; IMEX=1"""
ASKER
Hi expert,
They are not required. Also if I add them in, the compiler complains.
Ths,
JT
They are not required. Also if I add them in, the compiler complains.
Ths,
JT
They are required, otherwise the parser doesn't know how to combine the values together for the Extended Properties. If the compiler complains, you don't have enough double quotes. "Cannot find installable ISAM" means that you didn't create a valid connection string--period.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
IMEX=1, of course!
http://blogs.acceleration.net/ryan/archive/2005/01/11/477.aspx