Tuesday 21 February 2012

Java APIs for MS Office

Hello All,

Every now and then we always have to go through with this. We always have to do something programmatically with MS office documents, spreadsheet, power point etc.

Of course there are loads of such things exist to produce (extract) stuff in excel and pdf based format. However I had to travel an extra mile to produce an MS excel 2010 based report with loads of formatting, headings, legends etc. So I was forced to use something which can literally play with internals of such not so open formats.

Like I said in my previous post that Goggle is your best friend and I came across such a lovely Apache project for playing with such artifacts.

Apache POI is the one which best suited to me for various reasons apart from that it had everything I needed. It is so simple to use that I was able to kick start things in a matter of minutes. It offers many things but the one of my interest was POI-HSSF and POI-XSSF (for 2007 and 2010 based excel spreadsheets respectively)

There are so many Quick Guide references that you don't necessarily need to go through the whole documentation. I haven't used all of it as it was not needed for me but the offering is vast that it would meet all your needs.

I recommend to give it a try and produce something simple to start with.

Cheers,
Namish



Java based HTML Parser

Hello All,

Few days back I was thrown into a challenge to automate a report which was available only on internet as an HTML page. I initially thought it must be easy as the source must have exposed some APIs or services which I can consume. To my utter disappointment there was nothing like that but then they have the RSS feeds. To add more bitterness, unfortunately that was not good enough to produce the required report format.

I then had to find other methods of extracting data from source and after some brainstorming I came up with an idea of parsing the HTML itself. I thought it would be quick & easy to do and also a reliable way to go forward.

As a golden rule before I thought of creating my own HTML parser I did some goggling and to my shear surprise there are quite a few which exists. I then had to choose the right one for me and my choice became obvious when I got an open source based.

Jsoup it is. I downloaded the required library and you wont believe it was a simple 2 line of code and I was able to extract the data as per my needs. It offers so many ways to extract the data that I don't need to think about traversing nodes and their child nodes etc.

I recommend you to give it a try as it offers so much that you will surely be surprised like me.

In my next post I will highlight one more such utility libraries to play with MS and Open office products.

Cheers,
Namish

Monday 13 February 2012

World Clock

Sometimes back I was searching for a world clock for my desktop as it is very handy for people like me as we have to interact with people in different geography.

To my utter surprise, i got a fantastic one here. The reason I am saying about it my blog is because its Simple. You can see a live example of it in my blog on the top right corner.

Cheers,
Namish

Password in mind is different from your devices'

Hello Friends,


Changing passwords has become an important aspect of our life as we all are surrounded by so many applications/ gadgets that need security in some form. This is perfectly normal and required as well as we all know when there is good there is an evil.
Well my post if far more simpler and here I am not going to talk about to how to change, when to change your password etc.


The Problem:-
Lot of us are very familiar with the keyboard we use and we type most of the times without looking at it. This works fine till we keep on seeing what are we typing (hence we make corrections by using Del or Back Space keys).
Fields like password are always morphed (either show * or something similar), in this case you don't know what exactly you are typing, hence there is always 2 such fields to ensure that you are typing the same thing (for changing the passwords). This is exactly where the problem lies. 2 fields will ensure that you have typed the same value but there is no way to ensure that you have typed what you have intended. Often people do take care while changing the password but people often do mistakes as well. 


So in brief, If you are too familiar with your keyboard and you change your password without careful attention, it may happen that you type something else than intended (even though you have to type it twice). Now, when you try to log back in with the password in your mind and if you are typing it correct, you wont be allowed to log in for obvious reasons.


The Solution (Simple):-
Though it may look tricky to resolve but its not. If you are logged out of that device/machine etc. then take another machine with same keyboard (hope you have the right password there) and open a notepad type application. Type what you had intended as your password without looking at your keyboard and I can assure you that in max of 5 attempts you will realize the mistake you have done while changing your password.


Hope this helps.


Cheers,
Namish



Friday 10 February 2012

Live World Map on Desktop - Windows 7 Solution

Hello Friends,


This is my first post and hope you would like it.


Couple of days back I was goggling for Live World Map as a desktop wallpaper on my Windows 7 machine. Not to my surprise there were so many I could find but the only one I liked was this - Click here 


Unfortunate enough this was for Windows XP. Due to this very reason I got inspired and thought why don't we have something similar and simple for Windows 7 as well.


Well, not to be disappointed any more, here it is my (Simple) solution.


I have created a small java based program packaged into an executable jar which does the same thing and also doesn't impact your PC performance.


It has the following components:

  1. Executable Jar File and
  2. Properties file

Executable jar file will run in background and keep fetching the live image from http://static.die.net/earth/mercator/1600.jpg (however configurable but not recommended) at regular interval (can be set manually).


Properties file help you manage various properties of the application right from location, file names, refresh intervals to format and many more.


Now comes the most important questions
 Prerequisites

  • JRE (5 and above)
  • Windows 7

How to use it:

  • Download the zip file (containing the executable jar and properties file) here (File Size - 6KB only)
  • Create a folder in your desired location and extract the content.
  • Go to Resources folder and open the LiveWorldMapImageConfig.properties file and edit it with desired values. Description of all the properties are well documented inside it. Please follow the guidelines.
  • Once done just double click the jar file and you would soon notice 2 images (at the location you mentioned in properties file with the names you have provided).
  • You can verify the images by opening them in any picture viewer or editor of your choice.
  • Right click on your Windows 7 Desktop and click on Personalize.
  • Click on Desktop Background at the very bottom
  • Click the browse button next to Picture Location and browse it to where you have those 2 world map image files.
  • Ensure you click Select All.
  •  Adjust the Picture Position based on your screen size (Fill can work in almost all cases)
  • Adjust the time in "Change Picture every:" based on your preference or approximately to the value you have mentioned in properties file.
  • Click on Save Changes and you are done.



Now the live image will be fetched by the background java process and windows 7 will keep refreshing the desktop background at set interval to reflect the updated image.


As this is a background process and starts working only when you double click it there are 2 things you would want to do

  • At every start up (after shutdown) either double click the jar again or put it in your start up folder to ensure that this gets started every time you boot the machine.
  • At some point in time you may want to kill the program then you would have to use Task Manager and search for java process (the java process name would be your jvm process name - javaw32 or something like this) and Click on End Process



As with any other application, this too has few areas of improvements some are listed below

  1. Updates in properties require restart of your application
  2. In case you are sitting behind a proxy, there might be a proxy caching issue
  3. You can tell me...just post your thoughts, feedback and comments.



Also do let me know if you want to some other utilities.


Enjoy and Warm Regards,
Namish