AllExperts > Experts 
Search      

VB Script

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB Script Answers
Question Library

Ask a question about VB Script
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Dennis Cassøe
Expertise
ASP in many areas, to include them all would not be possible but some examples: Database access (SQL server, access) Forms Functions Components like aspsmartupload, aspupload, FileSystemObject, jmail And much more. Can`t always garenty an answer, but will do my best.

Experience
Have teached courses in ASP (for beginners)
Created
Knowledgebases
E-commerce applications
Ordinary updatable homepages

Organizations belong to
Aarhus School of Business, Denmark
Freelance programmer

Education/Credentials
Graduate student at the Aarhus School of Business, Denmark

 
   

You are here:  Experts > Computing/Technology > Basic > VB Script > Create Excel in asp

Topic: VB Script



Expert: Dennis Cassøe
Date: 7/2/2005
Subject: Create Excel in asp

Question
Sir i m using the following code:

<%
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.Open "GET", "http://localhost:81/ankit/test.htm", False
xml.Send
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("c:\test.xls",true)
fname.WriteLine xml.responseText
fname.Close
set fname=nothing
set fs=nothing
response.write a
Set xml = Nothing
%>

This code creates excel file successfully.But i use to conncet this excel file using
<%
Set cnnExcel = Server.CreateObject("ADODB.Connection")

cnnExcel.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
%>

It gives an error :External table is not in the expected format.
But when i open and save then it ask the location for save (why i dont know.?).Then i save it again on the same location i.e. C:/
Now After saving i m successfully connceted to excel file and can make a query.But after saving it manually.Can you please tell me why this file is not saved in C: when i using the above code.
I am trying it from last three days and get rid of.Please give me some solution as soon as possible.I vl be highly obligue to you.Its very urgent.
Regards
Ankit jain

Answer
Hi

Im not sure, but it could be, that when you create the excel file by importing test.htm, test.htm is not a correct excel file, and this is being corrected when you open it up in excel and save it from there, because it will probably then include the missing code in the file.

Therefore I would make two files, one that is downloaded from test.htm, and one that is like the one before, but this has been opened in excel and save there, then I would compare the two files and look for differences.

Dennis

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.