Read Excel file without changing its content

kar

I am trying to upload and read contents of an Excel file. It works fine if the content is in String format. But my content in the excel file is as follows:

02:02:02
03:03:03
04:04:04

All I want to do is retrieve the content as it is. But when I pull this data over, I end up getting the content as follows:

8.4745370370370374E-2
0.12711805555555555
0.169490740740741

Is there any way around to not change the content?

while (rowIterator.hasNext())
    {
        Row row = rowIterator.next();
        //For each row, iterate through all the columns
        Iterator<Cell> cellIterator = row.cellIterator();

        while (cellIterator.hasNext())
        {
            Cell cell = cellIterator.next();
            cell.setCellType(Cell.CELL_TYPE_STRING);
            //Check the cell type and format accordingly
            switch (cell.getCellType())
            {
                case Cell.CELL_TYPE_NUMERIC:
                System.out.print(cell.getNumericCellValue());
                break;

                case Cell.CELL_TYPE_STRING:
                System.out.print(cell.getStringCellValue());
                break;
            }
        }
    }
João Menighin

Your cell format is probably not set to Text. Check this out:

Cell type custom

Cell Type Text

As you can see, when you do not explicit set the cell type to text, excel tries to guess it. So when you are importing it, it is probably importing as Time. You may read it as Text, by explicit setting the cell type to Text and then typing the time 02:02:02, or you may read it as excel Time format and then convert it. Find out more about reading excel dates: How to read Excel cell having Date with Apache POI? Reading date values from excel cell using POI HSSF API

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Java Read a html file and save its content to a excel file

From Dev

How to copy formula without changing its content?

From Dev

How to read Excel File and populate its data in Grid in MVC without storing the Excel File anywhere?

From Dev

Replace a (powerpoint) shape in Excel VBA without changing its position number

From Dev

Python: add content to file without deleting its old content

From Dev

Python: add content to file without deleting its old content

From Dev

Read Zip file content without extracting in java

From Dev

Saving Excel File is changing the file access to read only

From Dev

Read Excel File with POI without header

From Dev

ways to read a text file in golfscript and print out its content

From Dev

Groovy - read file, modify its content and return it back

From Dev

In Android, would it be possible to open a file in the 'values' folder and to read its content?

From Dev

Write to a text file without duplicate or override its content

From Dev

How to open an Excel file with Python to display its content?

From Dev

Is it possible in Node to read in a file an export its contents (without exporting asyncronly)?

From Dev

how to read exact cell content of excel file in apache POI

From Dev

how to read exact cell content of excel file in apache POI

From Dev

Symfony 2: how to read excel file content usin PHPExcel

From Dev

Jquery: Changing Content of a div modifies its behaviour

From Dev

How can python pandas read excel file without unnamed columns

From Java

Subdivide a line into segments without changing its shape

From Java

Array changing its first letter without reason

From Dev

How to order IGrouping without changing its type?

From Dev

Stop Xorg without changing to its TTY

From Dev

Executing shell script without changing its environment

From Dev

How to read efficiently a huge text file in java and split its content to sort it?

From Dev

How to read efficiently a huge text file in java and split its content to sort it?

From Dev

How can I create a pseudo-file that gets its content from a command everytime it is read

From Dev

Save excel as pdf changing its orientation to horizontal

Related Related

  1. 1

    Java Read a html file and save its content to a excel file

  2. 2

    How to copy formula without changing its content?

  3. 3

    How to read Excel File and populate its data in Grid in MVC without storing the Excel File anywhere?

  4. 4

    Replace a (powerpoint) shape in Excel VBA without changing its position number

  5. 5

    Python: add content to file without deleting its old content

  6. 6

    Python: add content to file without deleting its old content

  7. 7

    Read Zip file content without extracting in java

  8. 8

    Saving Excel File is changing the file access to read only

  9. 9

    Read Excel File with POI without header

  10. 10

    ways to read a text file in golfscript and print out its content

  11. 11

    Groovy - read file, modify its content and return it back

  12. 12

    In Android, would it be possible to open a file in the 'values' folder and to read its content?

  13. 13

    Write to a text file without duplicate or override its content

  14. 14

    How to open an Excel file with Python to display its content?

  15. 15

    Is it possible in Node to read in a file an export its contents (without exporting asyncronly)?

  16. 16

    how to read exact cell content of excel file in apache POI

  17. 17

    how to read exact cell content of excel file in apache POI

  18. 18

    Symfony 2: how to read excel file content usin PHPExcel

  19. 19

    Jquery: Changing Content of a div modifies its behaviour

  20. 20

    How can python pandas read excel file without unnamed columns

  21. 21

    Subdivide a line into segments without changing its shape

  22. 22

    Array changing its first letter without reason

  23. 23

    How to order IGrouping without changing its type?

  24. 24

    Stop Xorg without changing to its TTY

  25. 25

    Executing shell script without changing its environment

  26. 26

    How to read efficiently a huge text file in java and split its content to sort it?

  27. 27

    How to read efficiently a huge text file in java and split its content to sort it?

  28. 28

    How can I create a pseudo-file that gets its content from a command everytime it is read

  29. 29

    Save excel as pdf changing its orientation to horizontal

HotTag

Archive