You are currently viewing JAVA Code to Create an Excel File in Relative Path

JAVA Code to Create an Excel File in Relative Path

Using excel files is one of the most common method for test data and other types of data management. The java code to create an Excel file is very easy and most of the code is self explanatory. Lets have a look at the same:
Eclipse needs to be pointed to the required JAR files in order to make it work with various functions provided by apache. Read more on Apache at it’s official website: Apache POI


The poi(s) need to be added to the project before running this code. Different versions may or may not support all functions and need to be worked with accordingly. Below is the snapshot of POI(s) used in my program. They can be downloaded from

Eclipse - Java Build Path
Eclipse-Java Build Path


Below is the JAVA class which creates an excel file in the “Relative Path”.

The code first checks for the directory “temp” at the relative path and creates if it does not exists.

Next, the excel file with three columns namely – “First Name”, “Last Name” and “Country”. If the file already exists, the code overwrites the same.

The code prints following on console when run the first time:
Directory already exists!
Excel File created: C:FunctionalTestAutomationproject_TestProject1tempMyExcelFile.xlsx
When we run the code second time, the console is as below:
Directory already exists!
Excel File created: C:FunctionalTestAutomationproject_TestProject1tempMyExcelFile.xlsx

Tada! That was one of the ways to write JAVA code and create an Excel file at the relative path. Hope it helped.

This Post Has 82 Comments

  1. Amita

    thank you..:)

  2. Allen Marry

    I like your post there is a lot of information about software testing, which i would like to learn, thank you for the great guide. Very useful post and I think it is rather easy to see from the other comments as well that this post is well written and useful.Keep up the good work.. Read more about QA Services


    Hi my friend! I wish to say that this post is
    awesome, nice written and come with almost all important
    infos. I’d like to look extra posts like this .

    my web site:

  4. sikis izle

    Remarkable! Its actually amazing piece of writing, I have got much clear idea on the topic of from this article. Karina Emelen Zacks

  5. film

    I was reading through some of your content on this website and I conceive this site is real informative! Retain posting. Goldina Zebedee Myrle

  6. film

    Im thankful for the blog article. Thanks Again. Great. Marga Germayne Wahlstrom

  7. erotik

    I really enjoy the blog post. Really looking forward to read more. Fantastic. Janifer Humfrid Cid

  8. erotik film izle

    Tremendous issues here. I am very happy to look your article. Pattie Wakefield Ackerman

  9. erotik film izle

    I am delighted that I noticed this website , exactly the right info that I was looking for! . Irena Jeth Ravi

  10. erotik film izle

    Great, thanks for sharing this blog post. Much thanks again. Great. Nicoline Tobit Pevzner

  11. erotik

    Muchos Gracias for your blog article. Really looking forward to read more. Cool. Zia Harlan Mistrot

  12. best CBD

    Wow, that’s what I was seeking for, what a information! existing here at this website, thanks admin of this website.

  13. CBD near me

    Hello it’s me, I am also visiting this site on a regular basis, this site is genuinely good and the people are
    actually sharing fastidious thoughts.

  14. best cbd for dogs with anxiety

    Hmm it looks like your site ate my first comment (it was super long) so I
    guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog.
    I too am an aspiring blog writer but I’m still new
    to everything. Do you have any helpful hints for newbie blog writers?
    I’d definitely appreciate it.

  15. best cbd oil for dogs

    Great post. I’m going through a few of these issues as well..

  16. CBD for dogs

    Do you mind if I quote a few of your posts as long as I provide credit and sources back to your blog?

    My blog site is in the exact same area of interest as yours and my users would
    truly benefit from a lot of the information you present here.
    Please let me know if this okay with you. Thank you!

    my page … CBD for dogs

  17. cbd for dogs

    Hi there! This article could not be written any better!

    Looking through this article reminds me of my previous roommate!
    He always kept preaching about this. I am going to forward this article to him.

    Pretty sure he’s going to have a great read. Many thanks for sharing!

  18. delta 8 thc store

    Hello There. I found your blog using msn. This is an extremely well written article.
    I will be sure to bookmark it and come back to read more of
    your useful info. Thanks for the post. I will definitely comeback.

    Also visit my website – delta 8 thc store

  19. delta 8

    Amazing! This blog looks exactly like my old one! It’s
    on a completely different subject but it has pretty much the same layout and design. Superb choice of colors!

    Feel free to visit my homepage … delta 8

  20. delta 8 thc

    I am not certain where you’re getting your information, however good topic.

    I needs to spend a while finding out much more or working out more.
    Thank you for fantastic info I was on the
    lookout for this info for my mission.

    my web page … delta 8 thc

  21. best delta 8 thc

    It is in point of fact a great and useful piece of info.

    I am happy that you shared this useful information with us.
    Please keep us informed like this. Thank you for sharing.

    Feel free to visit my web site: best delta 8 thc

  22. best delta 8 thc products

    I do not even know how I ended up here, but I thought this post was good.

    I don’t know who you are but definitely you are going to a famous blogger if you are not already 😉 Cheers!

    my web site: best delta 8 thc products

  23. delta 8

    Very nice post. I just stumbled upon your weblog and wanted to say that I have
    truly enjoyed browsing your blog posts. In any case
    I’ll be subscribing to your rss feed and I hope you write again very soon!

    Feel free to surf to my page … delta 8

  24. best delta 8 thc

    Wow, fantastic blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your web site
    is wonderful, as well as the content!

    Also visit my web page: best delta 8 thc

  25. buy delta 8 thc near me

    Everything is very open with a precise explanation of the
    challenges. It was truly informative. Your website is very useful.
    Many thanks for sharing!

    My web blog – buy delta 8 thc near me

  26. best delta 8 thc

    You can definitely see your expertise in the article you
    write. The sector hopes for more passionate writers
    like you who aren’t afraid to mention how they believe.
    Always go after your heart.

    Here is my web site – best delta 8 thc

  27. where to buy CBD

    Wow, this article is pleasant, my younger sister is analyzing such things, thus I am going to convey her.

    My blog: where to buy CBD

  28. gold bee

    I needed to thank you for this fantastic read!!
    I certainly enjoyed every little bit of it. I have you
    bookmarked to check out new things you post…

    My website gold bee

  29. cbd

    I got this web page from my pal who told me about this website and at
    the moment this time I am visiting this website and reading very informative content at this time.

    Feel free to visit my web-site cbd

  30. delta 8 near me

    Asking questions are genuinely good thing if you are not understanding anything
    totally, however this article provides nice understanding yet.

    Also visit my web blog – delta 8 near me

  31. Hey There. I discovered your weblog the usage of msn. That
    is an extremely well written article. I will make sure
    to bookmark it and come back to learn more of your useful
    information. Thanks for the post. I’ll certainly return.

    My page; area 52 delta 8 THC products

  32. best delta 8 thc carts

    Greetings from Ohio! I’m bored to tears at work so I decided to browse your site on my
    iphone during lunch break. I really like the info you provide here and can’t wait to take a look
    when I get home. I’m amazed at how fast your blog loaded on my cell phone
    .. I’m not even using WIFI, just 3G .. Anyways, wonderful site!

    my web blog – best delta 8 thc carts

  33. delta 8 area 52

    If you are going for finest contents like I do, just pay a visit this website everyday for the reason that it presents feature contents, thanks

    My homepage – delta 8 area 52

  34. delta 8 thc store

    Wonderful goods from you, man. I have understand your stuff previous to and you are just extremely
    great. I really like what you’ve acquired here, certainly like what you’re stating and the way in which you
    say it. You make it enjoyable and you still care for to keep it smart.

    I cant wait to read far more from you. This is really a tremendous site.

    My blog post :: delta 8 thc store

  35. where to buy CBD

    Hello there, You’ve done a great job. I’ll certainly digg it and personally recommend to my friends.

    I’m confident they’ll be benefited from this site.

    Also visit my blog post; where to buy CBD

  36. buy Google Voice

    Greetings! I’ve been reading your web site for a while now and finally got the bravery to go ahead and give you a shout out

  37. cbd

    Your style is very unique compared to other people
    I have read stuff from. I appreciate you for posting when you have the opportunity,
    Guess I will just book mark this blog.

    my web site: cbd

  38. This design is incredible! You most certainly know how to keep a reader amused.
    Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job.
    I really enjoyed what you had to say, and more than that, how you presented
    it. Too cool!

  39. gold bee

    Very good info. Lucky me I ran across your site by accident
    (stumbleupon). I’ve book-marked it for later!

    Also visit my webpage – gold bee

  40. delta 8 area 52

    My family every time say that I am killing my time here at web, but I know I am getting familiarity every day by reading such
    fastidious articles.

    Here is my homepage … delta 8 area 52

  41. Do you mind if I quote a few of your posts as long as I provide credit and sources back to your blog?

  42. SMM PAnnel BOSS

    Howdy extremely cool site!! Man .. Great ..


    Greetings! I’ve been reading your web site for a while now and finally got the bravery to go ahead and give you a shout out

  44. delta 8 carts

    This post gives clear idea in support of the new visitors of blogging,
    that really how to do blogging.

    my web blog … delta 8 carts

  45. Webhelpz

    Howdy extremely cool site!! Man .. Great ..

  46. best delta 8 thc carts

    Thanks on your marvelous posting! I definitely enjoyed reading it, you might be a
    great author.I will be sure to bookmark your blog
    and definitely will come back down the road. I want to
    encourage you to definitely continue your great posts, have a
    nice day!

    Feel free to surf to my page :: best delta 8 thc carts

  47. Amazing issues here. I’m very satisfied to look your article.
    Thanks a lot and I am having a look ahead to touch you.
    Will you kindly drop me a e-mail?

    my website :: best delta 8 thc carts

  48. best delta 8 carts

    I’m truly enjoying the design and layout of your site.
    It’s a very easy on the eyes which makes it much more
    enjoyable for me to come here and visit more often. Did you hire out a
    designer to create your theme? Outstanding work!

    Feel free to visit my web blog – best delta 8 carts

  49. This is the right website for anyone who hopes to understand this topic.
    You know a whole lot its almost hard to argue with you (not that I really would want to…HaHa).
    You certainly put a fresh spin on a subject which has been written about
    for ages. Wonderful stuff, just excellent!

    Also visit my blog post; delta 8 THC for sale area 52

  50. slot

    I think this is one of the most important info for me. And i’m glad reading your article.
    But wanna remark on few general things, The site style is perfect,
    the articles is really great : D. Good job, cheers

    my web page – slot

  51. slot online

    Hey there! I could have sworn I’ve been to this website before but after checking through some of the post I realized it’s new to me.
    Anyhow, I’m definitely delighted I found it and I’ll be bookmarking and checking back often!

    Feel free to visit my web-site :: slot online

  52. Buy Social Accounts

    I was so happy to discover you through Google. This is preciselywhat I was looking for.

  53. Gmail Pva Accounts

    I might want to thank you for the endeavors you have placed in writing this site. I’m expecting to look at a similar high-grade content from you later on too. Truth be told, your experimental writing capacities has urged me to get my own personal site now 😉

  54. US Magazine

    Howdy just wanted to give you a brief heads up and let you know a few of
    the pictures aren’t loading properly. I’m not sure
    why but I think its a linking issue. I’ve tried it in two
    different internet browsers and both show the same results.

    Also visit my web-site: US Magazine

  55. Observer

    Hey, thanks for the blog article. Really Great.

  56. seks homo

    Very neat post.Much thanks again. Great.

  57. kaiku

    Really informative blog post.Really thank you! Awesome.

  58. Amanda

    Greetings! Very useful advice within this article!
    It is the little changes that make the biggest changes. Thanks a
    lot for sharing!

Comments are closed.