• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Read Excel values and store in to Database

 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following code will read Excel sheet and print it to console, i want to read excel values and store in to Database.
Can you give me logic to read cells and store in to DB



 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rajendra Prakash wrote:Can you give me logic to read cells and store in to DB


No it doesn't work that way. What have you tried? What went wrong? What happened and what did you expect to happen?

And moving to Java in General.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From Excel sheet i read all the fields as string . In that date field is there , i am getting "dd/mm/yyyy" format.
But i want to convert this to "yyyy/mm/dd". i have tried with SimpleDateFormat class. But i could not get.
can you help me
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Why did SimpleDateFormate not work? Did it throw any exception or did not convert the date in the format you needed.
Let us know.

regds,
Amit
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
with the following code i can read multiple excel files in a single workbook and store in to database. Now
i want to read multiple workbooks and store in to db. can you give me any logic for this.

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Now i want to read multiple workbooks and store in to db. can you give me any logic for this.


There is a method that reads one file and stores something to the database - it sounds as if calling that method multiple times with different files would do the trick. Have you tried that? If so, what was the result? If not, tell us where you are stuck making progress.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No am not clear what you say. consider two folders , each consists one workbook . i want to read both workbooks and store in to db
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the "first" method reads one file and stores it to the DB, no? What is the problem with calling xlreader.first(..) repeatedly with different filenames?
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes , it is working fine. Now user can select workbook dynamically means , what i can do.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't follow - what difference does it make whether the user selects the file, or if the filename is hardcoded? The Excel/DB part would be the same, no?

If you're asking how a user can choose a file, start here: http://download.oracle.com/javase/tutorial/uiswing/components/filechooser.html

If you're asking something else, TellTheDetails. Your last two posts were very short, so it's hard to know what you have, and what problems you're encountering.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
consider i have a folder prakash,inside that i would like to find all excel files . Once i found all excel files i have read the same and store in to db
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, that's not hard. What do you have so far, and where are you stuck making progress? Are you familiar with the java.io package, particularly the File class and its methods? If not, that's where you should start.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
with the following code i can read multiple excel files. but now i want to read multiple excel files from single folder in
a single line. i dont want to call "first" method again and again. which means i want call excel file dynamically


 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

but now i want to read multiple excel files from single folder in a single line. i dont want to call "first" method again and again. which means i want call excel file dynamically.


Create a method that takes the name of the directory as parameter, and in that method iterate through all files in that directory. For each xls file you'd then call the first method.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
consider i have some 3 or 4 excel files.I dont know that files names , how can i read all files one by one
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The java.io.File class has methods for enumerating all files in a directory. You can then check their names in a loop, and only process those with appropriate file names (like with an "xls" extension).
reply
    Bookmark Topic Watch Topic
  • New Topic