Try outputting the data as a tab-delimited file vs. comma-separated. Set the
contentType
to application/vnd.ms-excel, set the contentLength.
Marty Hall's book "Core Servlets and Java Server Pages" ISBN 0-13-089340-4
has an example
of doing this with JSP on page 254-257
Hope that helps
Dave Bolt
ATSC/SPAWAR ASAT Team
Bolt's Law of Bandwidth - There is always plenty of network bandwidth, just
none for you.
-----Original Message-----
From: hua ge [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 20, 2000 10:52 PM
To: [EMAIL PROTECTED]
Subject: how to write comma delimited string which already contains
comma in some data?
Hi,
I have a jsp page which set proper header and write data out in comma
delimited format so the client can download it as a .csv file and open it in
Excel later .
the data columns are :
NAME SSN PHONE EMAIL
smith,susan 123-45-4567 123-456-7890 [EMAIL PROTECTED]
notice that the NAME column should contains lastname,firstname together with
comma separated.
my problem is since the NAME field already contains "," which is in this
format (LastName,FirstName). so if I treat NAME field as one whole field and
write out in comma delimited format, then later in the excel .csv file, the
name field actually will be displayed as two separate columns and expand the
whole line records as total 5 columns (actually should be 4 columns).
my client don't like to make the NAME column shown as
(fname lname) with no comma (if so, I will have no problem). they want the
(lname,fname) format for this column.
So I have to figure out how can I write the comma delimited string which
already contains comma in it???
I tried out.println(lname +"\"" + "," + "\"" + fname + "," +
SSN + "," +
PHONE + "," +
EMAIL );
it still break down NAME column as two columns with lname value as smith"
and fname value as "susan
can someone give me a hint? and help me out here??
Thanks in advance.
Helen Ge
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets