Click to See Complete Forum and Search --> : tab delimited text file


Skyscraper
07-18-2003, 05:31 PM
Hello,
I'm developing a web-based Database that takes datas from an Excel File. I would allow users to upload files in Excel (XLS) format and also in (TXT) format as tab-delimited text file. But I don't know how can I read a TXT file with ADO objects using ASP.
I know that if I rename a tab delimited (.TXT) text file with the .XLS extension, I can open it in MS-Excel; because Excel CAN read theese files.
So how can I read a tab delimited text file as an excel file?
To read Excel file I use the following instructions (ASP):

var objConn = Server.CreateObject("ADODB.Connection");
objConn.Provider = "Microsoft.Jet.OLEDB.4.0";
objConn.ConnectionString = "Data Source=" + file + ";" +
"Extended Properties=Excel 8.0";
objConn.Open();


Thanks for your reply

CrazyGaz
07-18-2003, 06:08 PM
well one possibility is that when they upload the text file to save it with an XLS extension.

dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile(FILE)
f.Copy("htdocs/imageupload/FILE.xls")
set f=nothing
set fs=nothing


Gaz

Skyscraper
07-19-2003, 04:35 AM
Originally posted by CrazyGaz
well one possibility is that when they upload the text file to save it with an XLS extension.

dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile(FILE)
f.Copy("htdocs/imageupload/FILE.xls")
set f=nothing
set fs=nothing
Gaz
I do exactly so, but when I try to read the saved XLS file:

objConn = Server.CreateObject("ADODB.Connection");
objConn.Provider = "Microsoft.Jet.OLEDB.4.0";
objConn.ConnectionString = "Data Source=" + file + ";" +
"Extended Properties=Excel 8.0";
objConn.Open();

I get an error:
Microsoft JET Database Engine (0x80004005)
The extern table is not in the expected format

I think that the above Extended Properties refer to a true Excel file not to a so saved file.

Because I've already done the routine to read excel files, I would not to use FSO directly to read the file.

CrazyGaz
07-19-2003, 04:43 AM
well I did a little test of my own and if this.

var objConn = Server.CreateObject("ADODB.Connection");
objConn.Provider = "Microsoft.Jet.OLEDB.4.0";
objConn.ConnectionString = "Data Source=" + file + ";" +
"Extended Properties=Excel 8.0";
objConn.Open();

can read a .xls file and if changing a .txt file to a .xls file will open file as a spreadsheet then I don't see any reason why it shouldn't work.

Skyscraper
07-19-2003, 05:37 AM
Originally posted by CrazyGaz
well I did a little test of my own and if this.

var objConn = Server.CreateObject("ADODB.Connection");
objConn.Provider = "Microsoft.Jet.OLEDB.4.0";
objConn.ConnectionString = "Data Source=" + file + ";" +
"Extended Properties=Excel 8.0";
objConn.Open();

can read a .xls file and if changing a .txt file to a .xls file will open file as a spreadsheet then I don't see any reason why it shouldn't work.

Maybe becauce a text file saved as a .xls can be read by excel, but is not the same thing as a true excel file, and the object ADODB.Connection can't read it with this connectionstring.
I hope that exists the right connectionstring to do so...