Tuesday, February 28, 2012

JAVA: Reading Excel File

This article will teach you on how to open and read Microsoft Excel 2010 file using Apache POI.

download Apache POI jar file here:

Below are the following code:


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class TestExcel {
     private static String localPath;
     private static String fileName;
     /**
       * @param args
       */
     public static void main(String[] args) {
         // TODO Auto-generated method stub
 InputStream inputStream = null;
 try {
      System.out.println("Reading Excel File: " +
                                 localPath + "/" + fileName);
      InputStream = new FileInputStream(localPath + "/" + fileName);
              XSSFWorkbook workBook = new XSSFWorkbook (inputStream);
              XSSFSheet sheet = workBook.getSheetAt(0);
              System.out.println("Getting sheet... ");
      int cellCount = 0;
      System.out.println("Cell counting... ");
      for(int i=0; i < 1; i++){
           XSSFRow rowHeader = sheet.getRow(i);
              cellCount = rowHeader.getLastCellNum();
      }
      System.out.println("cellcount: " + cellCount);
        for(int i=1; i < sheet.getLastRowNum() + 1; i++){
          XSSFRow row = sheet.getRow(i);
  System.out.println(row.getCell((short) 2));
      }
  } catch (FileNotFoundException e) {
      System.out.println(e.getMessage());
  } catch (IOException e) {
      System.out.println(e.getMessage());
  } 
     }
}

Monday, February 27, 2012

JAVA: Listing files


This article will teach you on how to get files on a specified directory and displaying its file name and size. Below are the following code:

import java.io.File;
public class TestFile {
    public static void main(String args[]) throws Exception {
          File folder = new File("D:/some folders");
          File[] listOfFiles = folder.listFiles();
          for (int i = 0; i < listOfFiles.length; i++) {
               if (listOfFiles[i].isFile()) {
                    System.out.println(listOfFiles[i].getName() 
                    + "," + listOfFiles[i].length() / 1024 + " KB");
               }
          }
     }
}

Wednesday, February 15, 2012

Last August 2011, I posted about the "A Perfect Gift from GOD"  and now with only one month to go and my baby will be born. My wife and I decided to have our baby named as Stephany Jillian Benito. Everyday I feel the excitement every time I see her moved in her mother's womb. I prayed for a normal delivery and a good health for my baby. Here are some pictures of us taken last January 2012.





See soon baby Stephany Jillian Benito...

Tuesday, February 14, 2012

It has been quite long time since the last I posted something on this blog of mine. I have been busy at work lately. Today I will resume blogging... Watch out guys! Happy Valentines Day to all...

Tuesday, October 4, 2011

Happy Birthday Master Rapper

Kaleidoscope World


So many faces, so many races
Different voices, different choices
Some are mad, while others laugh
Some live alone with no better half
Others grieve while others curse
And others mourn behind a big black hearse
Some are pure and some half-bred
Some are sober and some are wasted
Some are rich because of fate and
Some are poor with no food on their plate
Some stand out while others blend
Some are fat and stout while some are thin
Some are friends and some are foes
Some have some while some have most

Every color and every hue
Is represented by me and you
Take a slide in the slope
Take a look in the kaleidoscope
Spinnin' round, make it twirl
In this kaleidoscope world

Some are great and some are few
Others lie while some tell the truth
Some say poems and some do sing
Others sing through their guitar strings
Some know it all while some act dumb
Let the bassline strum to the bang of the drum
Some can swim while some will sink
And some will find their minds and think
Others walk while others run
You can't talk peace and have a gun
Some are hurt and start to cry
Don't ask me how don't ask me why
Some are friends and some are foes
Some have some while some have most

Every color and every hue
Is represented by me and you
Take a slide in the slope
Take a look in the kaleidoscope
Spinnin' round, make it twirl
In this kaleidoscope world
Related Posts Plugin for WordPress, Blogger...

Blog List