473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to insert text into an Excel file from a sql server database

28
I am working on a website and there is a need to export details that are stored on the database and put them in an excel file. I need to format the text such that each value appears in its own cell in that row. Right now they are all just appearing in one cell in that row.

The code I am using is shown below. The website is in classic ASP
Expand|Select|Wrap|Line Numbers
  1. ' Bulk Excel CSV export
  2.  
  3. If intShowPhoto = 5 then
  4.    Response.ContentType = "text/csv"
  5.     Response.Charset = "utf-8"
  6.     Response.AddHeader "Content-Disposition", "attachment; filename=Bulk_Exports.csv"
  7.     Do While Not objRecordset.EOF 
  8.     If objFirstName <> "" Then
  9.             Response.Write(objFirstName)
  10.             Response.Write("      ")
  11.             End If
  12.  
  13.             If objSurname <> "" Then
  14.             Response.Write(objSurname)
  15.             Response.Write("     ")
  16.             End If
  17.      If objTelMobile <> "" Then
  18.             Response.Write(objTelMobile)
  19.             Response.Write("     ")
  20.  
  21.         End If
  22.         If objEMail <> ""  Then
  23.            Response.Write(objEMail)
  24.            Response.Write(vbCRLF)
  25.  
  26.         End If
  27.  
  28.         objRecordset.MoveNext
  29.     Loop            
  30.     Response.End                
  31. End If
  32.  
Jan 12 '12 #1
5 2278
Rabbit
12,516 Expert Mod 8TB
That's because you haven't added any delimiters.
Jan 12 '12 #2
Rettla
28
how do i add those i am still new to vbscript
Jan 12 '12 #3
Rabbit
12,516 Expert Mod 8TB
You just need to write a comma after each field for a comma delimited file. Or a tab or a tab delimited file. Except at the end where you write a new line.

Also, it looks like you're not writing the new line if the email is a blank string. You have to write the new line no matter what.

And it looks like you're writing variables rather than the values in the recordset. That would be okay if you populated the variables with the values in the recordset but you don't do that.
Jan 12 '12 #4
Rettla
28
I did just that and it worked Thanks a lot I reali appreciate it
Jan 13 '12 #5
Rabbit
12,516 Expert Mod 8TB
No problem, good luck.
Jan 13 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Luis Esteban Valencia | last post by:
Hello Everyone, Iam an intermediate ASP.Net programmer and iam facing a challenging task. I have a table in MS-SQL server database called 'Members'. The table has following fields... ...
0
by: ramnaresh_t yadav via .NET 247 | last post by:
Hi, I am pasting the code to import data from Text/Excel files into Database(Oracle ) Table... I think some one needs this .. they can use.. it... ======================= Dim dsDB As New DataSet...
2
by: sympatico | last post by:
Heres the situation: I currently have an excel file with approximately 3500 project entries with fields such as job number, management, address, project description, type, etc., Is there a way...
4
by: sparty1022 | last post by:
we are constructing a (sql 2005) database on an FTP server where we will need to insert records into the tables. At this point our ftp scripts will allow us to upload/download documents/file from...
1
by: SSG | last post by:
How to insert date to the sql server database. I am getting input from the HTML form and store it to database using ASP. how to store date field, what datatype needed and what conversion...
1
by: f2002438 | last post by:
Dear all, i have a problem. i have to save a word doc or an excel file in the database in the module given to me where .net is the platform that i am using, can some one help me out in this....
9
by: TC | last post by:
Like a lot of database developers, I often choose Jet for the back- end. I'm starting to worry about what will happen when Jet is deprecated. Ostensibly, Jet users like me must switch to SQL Server...
1
by: kanmbk | last post by:
Hi, I supposed to upload the data of an excel file in to database. I dont know how to do this. Please help me. Bharathi..
0
by: robin1983 | last post by:
Hi, i have a code to download the data from database to excel file. The problem is that, everything is working fine. But, actually with my code, the field name is not coming. I want to download the...
6
by: sejal17 | last post by:
hello everyone, I want to import only 3 field of the excel file into database.how can i do it? Also i don't want to insert the duplicate value of that field.Please reply me as soon as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.