473,769 Members | 4,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'Save As' question

I am new to ASP so please pardon me if this is crazy.

I have data that I want to allow the user to be able to save in a format
that will then enable the user to open the data in Excel. (I have already
read the previous CSV posts and still have a question.)

I have an ASP page that takes some data from a previous page,adds some
column headings and displays it all in apparent CSV format.

All I am trying to do is allow the users to do a Save As (for a text or CSV
file) and open it (in Excel) with the proper columns. Somehow, although all
appears OK on the screen, when saving the file, line feeds seem to be added
and all the rows get messed up. If I simply select all the text on the ASP
page and copy it to WordPad, save it, and open it in Excel - all works fine.
Obviously there is some formatting I am overlooking.

Any suggestions would be helpful! (The page can be viewed at
http://primefreight.ca/database1_int...ck_company.asp and
search on TEST COMPANY as the company, press Track and then the Export
button.)

I am baffled and feel I am so close... but getting frustrated.
Thanks for any input!
Aliza
--
-----------------------------------
Aliza Klein
ab*****@optonli ne.net
-----------------------------------
Jul 19 '05 #1
4 3476
Aliza Klein wrote:
I am new to ASP so please pardon me if this is crazy.

I have data that I want to allow the user to be able to save in a
format that will then enable the user to open the data in Excel. (I
have already read the previous CSV posts and still have a question.)

I have an ASP page that takes some data from a previous page,adds some
column headings and displays it all in apparent CSV format.

All I am trying to do is allow the users to do a Save As (for a text
or CSV file) and open it (in Excel) with the proper columns.
Somehow, although all appears OK on the screen, when saving the file,
line feeds seem to be added and all the rows get messed up. If I
simply select all the text on the ASP page and copy it to WordPad,
save it, and open it in Excel - all works fine. Obviously there is
some formatting I am overlooking.

Any suggestions would be helpful! (The page can be viewed at
http://primefreight.ca/database1_int...ck_company.asp
and search on TEST COMPANY as the company, press Track and then the
Export button.)

While the code used to generate these results would be helpful, I do notice
that the header of the exported page contains this:
content="text/plain"
You would probably be better off setting the content type to
"applicatio n/vnd.ms-excel":
Response.Conten tType = "applicatio n/vnd.ms-excel"

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2
Thanks for the tip. I didn't know I could do that. Unfortunately, the
problem still remains. The code follows (as does the explanation):

<%
tmp = ""
response.conten ttype = "applicatio n/vnd.ms-excel"
response.write "Container #,Vessel Name,Company Name,House Bill of Lading
#,Shipper,Count ry,Cargo Control #,ETD Origin,ETA (Halifax/Vancouver),ETA
(Montreal),Revi sed ETA,Current Location of Cargo,Delivery Status,Customs
Clearance Status,OBL Required,Number of Cartons,Weight (kg),Cubic Meters
(CBM),PO #,PO # (2),Comments #1,Comments #2,Comments #3,Comments #4,Comments
#5,Reference #" & "<BR>"
For each item in Request.form
For icount = 1 to Request.Form(It em).Count
if Item = "export_stu ff" then
tmp = tmp & Request.form(it em)(icount)
tmp = ConvertString(t mp)
response.write "'" & tmp & "'" & vbCrLF
end if
next

next

%>

<% function ConvertString(s trMy)
dim strRetVal
strRetVal = strMy
strRetVal = replace(strRetV al, "!!!","','" , 1, -1, 1)
ConvertString = strRetVal
end function
%>

Explanation: Basically, I write a comma delimited string to the screen and
then a string (that I first convert - long story) that containes all the
text that I want that is passed from the previous page. The reason I did it
this way is that I often return more than one record and when I did it field
by field, the data was grouped together (ie: both record's data under 1
field). I hope this makes sense to you.

And thanks!
Aliza
"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:%2******** **********@TK2M SFTNGP10.phx.gb l...
Aliza Klein wrote:
I am new to ASP so please pardon me if this is crazy.

I have data that I want to allow the user to be able to save in a
format that will then enable the user to open the data in Excel. (I
have already read the previous CSV posts and still have a question.)

I have an ASP page that takes some data from a previous page,adds some
column headings and displays it all in apparent CSV format.

All I am trying to do is allow the users to do a Save As (for a text
or CSV file) and open it (in Excel) with the proper columns.
Somehow, although all appears OK on the screen, when saving the file,
line feeds seem to be added and all the rows get messed up. If I
simply select all the text on the ASP page and copy it to WordPad,
save it, and open it in Excel - all works fine. Obviously there is
some formatting I am overlooking.

Any suggestions would be helpful! (The page can be viewed at
http://primefreight.ca/database1_int...ck_company.asp
and search on TEST COMPANY as the company, press Track and then the
Export button.)
While the code used to generate these results would be helpful, I do

notice that the header of the exported page contains this:
content="text/plain"
You would probably be better off setting the content type to
"applicatio n/vnd.ms-excel":
Response.Conten tType = "applicatio n/vnd.ms-excel"

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #3
Aliza Klein wrote:
Thanks for the tip. I didn't know I could do that. Unfortunately,
the problem still remains. The code follows (as does the
explanation):

<%
tmp = ""
response.conten ttype = "applicatio n/vnd.ms-excel"
response.write "Container #,Vessel Name,Company Name,House Bill of
Lading #,Shipper,Count ry,Cargo Control #,ETD Origin,ETA
(Halifax/Vancouver),ETA (Montreal),Revi sed ETA,Current Location of
Cargo,Delivery Status,Customs Clearance Status,OBL Required,Number of
Cartons,Weight (kg),Cubic Meters (CBM),PO #,PO # (2),Comments
#1,Comments #2,Comments #3,Comments #4,Comments #5,Reference #" &
"<BR>"
For each item in Request.form
For icount = 1 to Request.Form(It em).Count
if Item = "export_stu ff" then
tmp = tmp & Request.form(it em)(icount)
tmp = ConvertString(t mp)
response.write "'" & tmp & "'" & vbCrLF
end if
next

next

%>

<% function ConvertString(s trMy)
dim strRetVal
strRetVal = strMy
strRetVal = replace(strRetV al, "!!!","','" , 1, -1, 1)
ConvertString = strRetVal
end function
%>

Explanation: Basically, I write a comma delimited string to the
screen and then a string (that I first convert - long story) that
containes all the text that I want that is passed from the previous
page. The reason I did it this way is that I often return more than
one record and when I did it field by field, the data was grouped
together (ie: both record's data under 1 field). I hope this makes
sense to you.

And thanks!
Aliza


You need to but the data into a table. This works for me:

<%
Response.Buffer =true
Response.Conten tType = "applicatio n/vnd.ms-excel"
tmp = "Container #,Vessel Name,Company Name," & _
"House Bill of Lading#,Shipper ,Country,Cargo Control #," & _
"ETD Origin,ETA (Halifax/Vancouver),ETA( Montreal),Revis ed ETA," & _
"Current Location of Cargo,Delivery Status," & _
"Customs Clearance Status,OBL Required,Number of Cartons," & _
"Weight (kg),Cubic Meters(CBM),PO #,PO # (2),Comments #1," & _
"Comments #2,Comments #3,Comments #4,Comments #5,Reference #"
Response.Write "<table><tr><td >"
response.write replace(tmp,"," ,"</td><td>")
Response.Write "</td></tr></table>"
%>

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #4
Thanks so much! That set me on the right path!

I am up and running....

Aliza

"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:Oy******** ******@TK2MSFTN GP10.phx.gbl...
Aliza Klein wrote:
Thanks for the tip. I didn't know I could do that. Unfortunately,
the problem still remains. The code follows (as does the
explanation):

<%
tmp = ""
response.conten ttype = "applicatio n/vnd.ms-excel"
response.write "Container #,Vessel Name,Company Name,House Bill of
Lading #,Shipper,Count ry,Cargo Control #,ETD Origin,ETA
(Halifax/Vancouver),ETA (Montreal),Revi sed ETA,Current Location of
Cargo,Delivery Status,Customs Clearance Status,OBL Required,Number of
Cartons,Weight (kg),Cubic Meters (CBM),PO #,PO # (2),Comments
#1,Comments #2,Comments #3,Comments #4,Comments #5,Reference #" &
"<BR>"
For each item in Request.form
For icount = 1 to Request.Form(It em).Count
if Item = "export_stu ff" then
tmp = tmp & Request.form(it em)(icount)
tmp = ConvertString(t mp)
response.write "'" & tmp & "'" & vbCrLF
end if
next

next

%>

<% function ConvertString(s trMy)
dim strRetVal
strRetVal = strMy
strRetVal = replace(strRetV al, "!!!","','" , 1, -1, 1)
ConvertString = strRetVal
end function
%>

Explanation: Basically, I write a comma delimited string to the
screen and then a string (that I first convert - long story) that
containes all the text that I want that is passed from the previous
page. The reason I did it this way is that I often return more than
one record and when I did it field by field, the data was grouped
together (ie: both record's data under 1 field). I hope this makes
sense to you.

And thanks!
Aliza


You need to but the data into a table. This works for me:

<%
Response.Buffer =true
Response.Conten tType = "applicatio n/vnd.ms-excel"
tmp = "Container #,Vessel Name,Company Name," & _
"House Bill of Lading#,Shipper ,Country,Cargo Control #," & _
"ETD Origin,ETA (Halifax/Vancouver),ETA( Montreal),Revis ed ETA," & _
"Current Location of Cargo,Delivery Status," & _
"Customs Clearance Status,OBL Required,Number of Cartons," & _
"Weight (kg),Cubic Meters(CBM),PO #,PO # (2),Comments #1," & _
"Comments #2,Comments #3,Comments #4,Comments #5,Reference #"
Response.Write "<table><tr><td >"
response.write replace(tmp,"," ,"</td><td>")
Response.Write "</td></tr></table>"
%>

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
25030
by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or less complex technical calculations, several input variables. I would like to equipp the starting panel with the usual New, Open, Save, Save As, Close etc. menus (like in Excel, or Word, etc.) What is the best way to accomplish Save, or Save As?...
9
3030
by: Ivan Demkovitch | last post by:
Hi! I would like to know if I can save File on Server using server-side code? For example, I like to create thumbnail images and populate specific directory. Do I need specific permissions to do this? (I use public host) Thanks!
7
1271
by: Shanli RICHEZ | last post by:
I'm using ASP.NET and quite a lot of object in memory instead of a database. The question is that I tried to save the data, serialize them in a XML file to save them when the application is ending. event : Application_End in Global.asax. But the object are not accesible from there so I can't save them. Any idea ???
3
2553
by: B-Dog | last post by:
I'm checking some files to see if the filenames are in a certain format and if not I want to pull up a dialog box that gives me a save as with the file that is in question. I have all the files in a certain directory and if it doesn't meet my criteria then I want to do a "save as" to a different location. How can I do that. I can't seem to get the save as dialog to grab the filename of the file in question and ask for a place to save it....
2
1679
by: Peter Proost | last post by:
Hi group when save a bitmap called saveBmp like this: <<<< saveBmp.Save(filename, ImageFormat.Jpeg) <<<< the bitmap gets saved with it's size propertys, so if I right click the file and select propertys I can see the width and the height of the image. But if I save the bitmap as a bitmap:
2
2474
by: zheng | last post by:
ÇçÌì I have a word document and it has a picture object, I want save the picture object as other single picture file by C# program. I have a idea, by clipboard, copy the picture to clipboard, and then save as a file from clipboard, it is work well in application,but don't work in a web application. how can I to do? and are there other ideas to save the picture object in web application? help me !!
5
2663
by: C Watson | last post by:
Hi, I'm wondering if anyone can help me with AJAX in ASP.NET 1.1. I have a very specific feature that I would like to use it for. I have a rather long form that the users use to enter data during a phone call with a client. Since it's long, I put six Save buttons down the length of the form and asked the users to save often. When they click the Save buttons, the data is saved to a central database and a text label is changed to say...
3
8563
by: fiefie.niles | last post by:
I would like to save a web page to a file and have the hyperlinks work when I bring the file back up. If the web page has a hyperlink like the following <a href="OurWeb/News/abcFile.htm">, after saving the file and showing it on the screen, and you try to click on the link, it will try to go to C:\OurWeb\News\abcFile.htm instead of www.MyWebSite.com/OurWeb/News/abcFile.htm. If I am on the website www.MyWebSite.com, and do "File" - "Save...
12
4776
by: =?Utf-8?B?RnJlZU5FYXN5?= | last post by:
Hello, the scenario: There's an ASPX page which shows some text and has three buttons at the bottom: Save, Print and Close. Print and close is done by javascript. But how can I save the page on the client's computer? He/she could do this using the browser (file/save), but I need to have it done by pressing the pushbutton. In my serverside code I get the button-click-event, I also know how to get
3
2608
by: Koliber (js) | last post by:
sorry for my bad english when I fire up (from my c# code) a standard "file - save as " dialog, and when chosen location is a shered local network directory, where I do have rights to create and modify files, but I do not have rights to delete one, (and do save as with my filename) then this standard windows dialog seem to create empty
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9416
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10199
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9850
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8862
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7396
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.