• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading & writing to Excel spreadsheets  RSS feed

 
Neha Parab
Greenhorn
Posts: 10
Firefox Browser PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I'm trying to read numeric data from a text file & I want to write each number in a seperate cell in an Excel spreadsheet. Can somebody help ???

Input data is as below:
3008,45,14,277,10,6371,223,208,116,3036,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,2
2893,114,16,108,30,5066,245,223,102,4340,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,2

I want each value in a different cell.

Please help. Its kinda urgent

With regards
jspnooby
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several Java libraries that help you to work with Excel files. See our FAQ page Accessing File Formats for links.
 
Neha Parab
Greenhorn
Posts: 10
Firefox Browser PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong,

I know there are lot of Lib's available. I was trying to use Apache POI. But its too confusing. It would be nice if you could give some hint.

With regards,
jspnooby
 
Tim Moores
Saloon Keeper
Posts: 4032
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The POI web site has many examples that are not particularly hard to follow. What, specifically, are vou having problems with?
 
Neha Parab
Greenhorn
Posts: 10
Firefox Browser PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores,

I have data in a text file as follows:

3008,45,14,277,10,6371,223,208,116,3036,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,2

I want to write it to an excel file, with each value in separate cell.



With regards
jspnooby
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check out the examples on the POI site as Tim mentioned?
 
Neha Parab
Greenhorn
Posts: 10
Firefox Browser PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh,

I did go through those examples. They confuse me more. Following the examples I have reached till here in the code:




I still need to write the contents of covtype1.data in the excel sheet
Please guide me.

With regards
jspnooby
 
Tim Moores
Saloon Keeper
Posts: 4032
94
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The input data looks like CSV. If this was my problem I'd use a CSV library to handle it, but if you're certain that it will always only contain integer numbers, then a BufferedReader combined with String.split(",") will work as well.
 
Neha Parab
Greenhorn
Posts: 10
Firefox Browser PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim,

can you elaborate a bit more.

jspnooby
 
Tim Moores
Saloon Keeper
Posts: 4032
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Elaborate on what? How to use BufferedReader and String.split? Those are pretty basic classes/methods that just about any Java tutorial (including Oracle's) should cover, or you can just learn about them through some experimentation.
 
Neha Parab
Greenhorn
Posts: 10
Firefox Browser PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey there,

still not able to insert each value in a different cell.
this is my code:




please tell me where I'm going wrong

With regards,
jspnooby
>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!