Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2013
    Posts
    4
    Rep Power
    0

    Default Data getting overwritten in excel using apache poi.. need to get appended in next row

    Hai,
    How to go to next row and print the data in excel using java apache poi.. instead of overwritting existing data..
    below is the code i have written pls correct

    private static void excelLog(int row, int col, String value)

    {
    HSSFRow myRow = mySheet.getRow(row);

    if (myRow == null)
    {
    myRow = mySheet.createRow(row);
    }



    /*else
    {
    Iterator<Row> rowIterator = mySheet.iterator();
    while(rowIterator.hasNext()) {
    myRow = mySheet.createRow(row);
    }*/


    }

    HSSFCell myCell = myRow.createCell(col);
    myCell.setCellValue(value);
    }

    public void writeDataExcel(ArrayList<String> inpList) {
    int numCol = 100;
    int index = 0;
    for (int i = 0; i < 100; i++) {
    for (int j = 0; j < numCol; j++) {
    if(index < inpList.size())
    excelLog(i, j, inpList.get(index++));
    }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default Re: Data getting overwritten in excel using apache poi.. need to get appended in next

    Please use [code] tags [/code] when posting code in order to retain the formatting.
    That code doesn't look valid to me.
    Looks like too many '}'.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    erdsingh is offline Member
    Join Date
    Jan 2014
    Posts
    4
    Rep Power
    0

    Default Re: Data getting overwritten in excel using apache poi.. need to get appended in next

    please refer javabestinfo.com/excel-poi-utils.html to get understand excel apache poi utility methods

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    927
    Rep Power
    2

    Default Re: Data getting overwritten in excel using apache poi.. need to get appended in next

    Please don't wake up sleeping threads with your site spam.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. Excel to Html Conversion using apache poi library
    By agastheswar in forum New To Java
    Replies: 5
    Last Post: 05-09-2014, 11:28 AM
  2. Replies: 1
    Last Post: 01-24-2013, 09:30 AM
  3. Replies: 5
    Last Post: 08-02-2012, 12:55 PM
  4. Generate Excel using Apache POI
    By sarwan in forum New To Java
    Replies: 0
    Last Post: 06-08-2010, 11:17 AM
  5. Adding multiple sheets in Excel (apache POI)
    By javanewbie in forum Advanced Java
    Replies: 0
    Last Post: 06-22-2009, 04:51 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •