aspose file tools*
The moose likes Java in General and the fly likes Viewing a CSV File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Viewing a CSV File" Watch "Viewing a CSV File" New topic
Author

Viewing a CSV File

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
I have this file path but I can not get it to display with the following code. See comments under CSV option:

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

The proper MIME type for CSV files is text/csv. It's then up to the browser to properly deal with it. That's apparently where it goes wrong.

If you save the CSV file instead, does it contain the right data? What happens if you open that saved CSV file by double clicking it?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
Rob Spoor wrote:The proper MIME type for CSV files is text/csv. It's then up to the browser to properly deal with it. That's apparently where it goes wrong.

If you save the CSV file instead, does it contain the right data? What happens if you open that saved CSV file by double clicking it?


http://simplyw/drawings/Openfiles/files.csv

If I use the text/csv and the open option the dialog appears asking what program to use. If I choose excel it opens with no data.

If I use the Save option the file saves okay but it is empty.

If I go to the actual file and double click it opens in excel.

If I use the path in browser window it also opens an excel file.

I have done one more thing. If I place the url in a link it works okay also. The above tries have been using the window.open(url) method.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Steve Dyke wrote:


There's a problem between those two lines of code. The second line expects the "filePath" variable to be a file path. The first line says it isn't one.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
Paul Clapham wrote:
Steve Dyke wrote:


There's a problem between those two lines of code. The second line expects the "filePath" variable to be a file path. The first line says it isn't one.


This all works when the file type is a .pdf. I don't understand.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Then I think it's time to go back and look at what "can not get it to display" actually involves. Error messages? Something else displays? You know, the usual identification of the symptoms of the problem.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
Paul Clapham wrote:Then I think it's time to go back and look at what "can not get it to display" actually involves. Error messages? Something else displays? You know, the usual identification of the symptoms of the problem.


In my original post, within the code part of the csv option I gave comments as to what was happening. I have figured out as I mentioned a couple of posts ago if I bypass the window.open(url) method and just hard code a link to the url it works fine. By the way thanks for your help in this issue.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

Paul is right. You can only use FileInputStream with files on your local hard disk, and maybe on some shares (Windows shares, NFS).
To read files from a URL, you should use java.net.URL and its openStream() method to get an InputStream.

My guess is that if you check your log files you will see an exception printed to it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Viewing a CSV File