Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8501559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:14:45+00:00 2026-06-11T01:14:45+00:00

I am generating a CSV file on the fly/runtime with JSF and the code

  • 0

I am generating a CSV file on the fly/runtime with JSF and the code is as follows

FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = HttpServletResponse)context.getExternalContext().getResponse();

int read = 0;
byte[] bytes = new byte[1024];

response.setContentType("text/csv");
response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");

ServletOutputStream os = null;

StringBuffer stringBuffer1 = new StringBuffer("");

stringBuffer1.append("Disconnect Time");
stringBuffer1.append(',');
stringBuffer1.append("Calling Number");

stringBuffer1.append("01/06/2010 01:00:35 AM");
stringBuffer1.append(", ");
stringBuffer1.append("447744369900");


ByteArrayInputStream bis1;
try {
    bis1 = new ByteArrayInputStream(stringBuffer1.toString().getBytes("UTF-8"));

    os = response.getOutputStream();

    while ((read = bis1.read(bytes)) != -1) {
        os.write(bytes, 0, read);
    }

    os.flush();
    os.close();
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

FacesContext.getCurrentInstance().responseComplete();

and below is the content of the file when opened

Disconnect Time Calling Number
1/6/2010 1:00   4.47744E+11

The Actual expected result will be complete date format w.r.t AM/PM and number in complete length.

I have already tried example of double quotes as given Excel CSV – Number cell format and some other of adding blank space but they did not worked. Also the user will be performing arithmetic operation on the number columns.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:14:46+00:00Added an answer on June 11, 2026 at 1:14 am

    I’m no JSF expert but this seems entirely related to how Excel reads this information.

    I tried playing a bit with the data, but could not make it do what you want it to do in CSV.

    I created a sample CSV file with this content (using Nopepad++):

    Disconnect Time, Calling Number
    01/06/2010 01:00:35 AM,447744369900
    

    And when I viewed it using Excel it gave me the same output you got – so the question you are facing is related to showing CSV in Excel – and not JSF.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm generating a CSV file from the following code public ActionResult Index() { var
I am generating csv file and it force close, why? my code is package
I am using C++ and I am generating a csv file to report some
I have a large nested array that I'm generating from parsing a CSV file
I have a script that generates a csv file using the following code: header('Content-type:
I am generating a CSV file from Ruby. The problem is a column string
I have an XSL file that I am generating from CSV from and Object
i am generating CSV,the file is generated very fine but i have problem in
I am generating a CSV file containing data from a MYSQL database. There are
using python i am generating a KML file from a csv file containing lat/long

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.