• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Reading & writing to Excel spreadsheets

 
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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • 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
 
Saloon Keeper
Posts: 6080
154
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • 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
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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: 6080
154
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • 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: 6080
154
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • 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
>
 
Climb the rope! CLIMB THE ROPE! You too tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!