With *poi*
*
*
I have written this method
===

public class ReadExcelFile {

    public static void main(String[] args) {
//resources
        String fileName =
"/home/nirajnijju/nijju/devlopment/excel_to_sql/test1.xls";
        Vector dataHolder = ReadCSV(fileName);
        printCellDataToConsole(dataHolder);
    }

    public static Vector ReadCSV(String fileName) {
        Vector cellVectorHolder = new Vector();

        try {
            FileInputStream myInput = new FileInputStream(fileName);

            POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);

            HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);

            HSSFSheet mySheet = myWorkBook.getSheetAt(0);

            Iterator rowIter = mySheet.rowIterator();

            while (rowIter.hasNext()) {
                HSSFRow myRow = (HSSFRow) rowIter.next();
                Iterator cellIter = myRow.cellIterator();
                Vector cellStoreVector = new Vector();
                while (cellIter.hasNext()) {
                    HSSFCell myCell = (HSSFCell) cellIter.next();
                    cellStoreVector.addElement(myCell);
                }
                cellVectorHolder.addElement(cellStoreVector);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return cellVectorHolder;
    }

    private static void printCellDataToConsole(Vector dataHolder) {
        //LinkedList<String> row = new LinkedList<>;
        Vector row = new Vector();
        for (int i = 0; i < dataHolder.size(); i++) {
            Vector cellStoreVector = (Vector) dataHolder.elementAt(i);
            for (int j = 0; j < cellStoreVector.size(); j++) {
                HSSFCell myCell = (HSSFCell) cellStoreVector.elementAt(j);
                String stringCellValue = myCell.toString();
                System.out.print(stringCellValue + "\t");
            }
            System.out.println();
        }
    }
}




Regards,

*Niraj Kumar*

B.Tech. CSE
Class of 2012
ISM, Dhanbad
8274952350



On Tue, Jun 4, 2013 at 10:09 AM, Chameera Wijebandara <
[email protected]> wrote:

> you can try this
>
> http://poi.apache.org/
>
> On Tue, Jun 4, 2013 at 9:49 AM, karthikeyan balamurugan
> <[email protected]> wrote:
> > Guys i need to edit and save the excel sheet in java.
> >
> > If i click the new button i have to show the worksheet like excel in
> java.
> >
> > and then edit and save the file like excel sheet.
> >
> > I 've tried lot but it creates the workbook only and i have to load a
> > worksheet in java and save as a excel file.
> >
> > i've use the jxl.jar 2.6.12 file to implement this.
> >
> > how could i load a worksheet in java and save as excel file
> >
> > is there any sample source code link send me guys
> >
> > Regards
> >
> > Karthikeyan
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Code Jam" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > To post to this group, send email to [email protected].
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/google-code/CAHbvNaBixAUB2HJZbpTr_H_ud%2BhqLL3aL26WDqU%2BVhOe%2BOazBw%40mail.gmail.com?hl=en
> .
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
>
>
> --
> ----------------------------------------------------------
> Chameera Wijebandara,
> Undergraduate Department of Computer Science and Engineering,
> University of Moratuwa,
> Sri Lanka.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/CAOjq%2B76dM7BXZLXCd9Q1r-T3h4AVbhdeoskBRv4D3CCnBgKA5w%40mail.gmail.com?hl=en
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAJT%2BMft-T6s%3D84p-%3D1Rh2_FKkSTwkv2skNaHUp-j%3DcGwZVaFbA%40mail.gmail.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to