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

  • Home
  • SEARCH
  • 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 7818731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:40:39+00:00 2026-06-02T06:40:39+00:00

I wrote some code to extract data from xls and save them into csv.

  • 0

I wrote some code to extract data from xls and save them into csv. Everything is working great except when I have a time value, it is changing it to a date. How can I avoid that?
For example, if in the xls file it is 119:22:00, it is getting saved to the csv file as 1/4/1900 23:23 with format type as date. How can I keep it the way it is with format as String?

Here is the code:

if (sheet != null)
{
    for (currentRow = 0; currentRow < sheet.getRows(); currentRow++)
    {
        row = new ArrayList<String>();
        Cell[] rowCells = sheet.getRow(currentRow);
        for (Cell cell : rowCells)
        {
            System.out.println(cell.getContents());
        }
    }
}
  • 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-02T06:40:40+00:00Added an answer on June 2, 2026 at 6:40 am

    You need to get the Excel.Cell.Text rather than the Excel.Cell.Value to see the formatted value. Clearly what you’re extracting is the value. Based on your code, it looks like the problem will be in cell.getContents() or sheet.getRow() – whichever is used to extract the data from excel. You should post the content of those functions too.

    The underlying values for dates and times in Excel are very hard to deal with, and meaningless to the novice user in their raw format. You can see the underlying value Excel translates your dates and times to just by opening up your excel sheet and temporarily changing the format to number. You’ll see that as soon as you type in a date or time, it’s translating it to a numeric representation of that date or time that will be meaningless to the user, and thus meaningless to you if you extract the underlying value rather than the formatted text.

    enter image description here

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

Sidebar

Related Questions

I'm trying to write a code to extract some form data from a HTML
I'm trying to write some code to extract Exif information from a JPG. Exif
I wrote some code for the ising model in python (2d). Everything looks seems
yesterday i did ask about how to extract some data from a complicated xml
I'm using some code to extract from a Google Url the keyword of the
I wrote some code with a lot of recursion, that takes quite a bit
I wrote some code recently (ISO/ANSI C), and was surprised at the poor performance
I wrote some code to read a file in my Java Servlet class. (I'm
I wrote some code which monitors the output of Stopwatch using a tight loop.
I wrote some code (Java and LDAP) to create a user in the Active

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.