javacsvopencsvdate

Wrong date view in Excel


I have a Java app that reads the database and generates a CSV file containing a ResultSet. I generated the CSV file using opencsv. Everything is fine except the date field. When I open the CSV file in Excel, it shows the date fields with "################". If I click twice in a date field, then it shows the date. Does anyone know what is wrong with this?


Solution

  • It's not the problem with code or opencsv, Microsoft Excel might show ##### in cells when a column isn’t wide enough to show all of the cell contents. Formulas that return dates and times as negative values can also show as #####.

    So try to increase the column width.

    for more info: https://support.office.com/en-us/article/How-to-correct-a-error-bf801d0a-2a6e-44bd-a70e-0f780ae8f11e