Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7499649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:53:51+00:00 2026-05-29T19:53:51+00:00

I am new to Apache-poi and using 3.8 version of poi. While writing value

  • 0

I am new to Apache-poi and using 3.8 version of poi. While writing value in the Excel,i check for the column names if they matched, i will write some value in that column and finish it, and again i will start writing on header. The problem is if write three column values only last column values are add or saved and first two values are not saved in the column. Can anyone tell what went wrong.
(sorry, in case any mistake)

 Code:
            int i = 0;
        Row row = sheet.createRow(i);
        CellStyle cellStyle = workbook.createCellStyle();
        cellStyle.setFillBackgroundColor(HSSFColor.LIGHT_ORANGE.index);
        String validate_header = null;
        while (iterator.hasNext()) {
            if (eiterator.hasNext()) {
                validate_header = eiterator.next();
            }
            Cell cell = row.createCell(i);
            String col_heading = iterator.next();
            cell.setCellValue(col_heading);
            if(col_heading.equalsIgnoreCase("Assigned Date"))
            {
                Add_value(i, col_heading, row, sheet);
                row=sheet.getRow(0);
                cell=row.getCell(i);
            }
            else if(col_heading.startsWith("Review"))
            {
                int count=-1;
                int n=Col_values.get("Defect Summary").size();
                for (int j = 0; j < n; j++) {
                            row = sheet.createRow(count);
                    cell = row.createCell(i);
                    String s="External QC Defect ";     
                    cell.setCellValue(s);
                    count++;

                }
                row=sheet.getRow(0);
                cell=row.getCell(i);

            }

            sheet.autoSizeColumn(i);
            i++;

        }

private static Sheet Add_value(int k,String name,Row row, Sheet sheet) {

        System.out.println("Inside the add method");


        if(name.equalsIgnoreCase("Assigned Date")||name.equalsIgnoreCase("Reported Date") )
        {
        vector = Col_values.get("TargetDate");
        int count = 1;

        System.out.println("IF Size of the vector  " + vector.size());
        for (int j = 0; j < vector.size(); j++) {

            row = sheet.createRow(count);
            cell = row.createCell(k);
            String s = (String) vector.get(j);
            System.out.println(s);
            cell.setCellValue(s);
            count++;

        }
        }
        else
        {
        vector = Col_values.get("Defect Summary");
            int count = 1;
    System.out.println("ELSE Size of the vector  " + vector.size());
        for (int j = 0; j < vector.size(); j++) {

            row = sheet.createRow(count);
            cell = row.createCell(k);
            String s = (String) vector.get(j);
            System.out.println(s);
            cell.setCellValue(s);
            count++;
        }
        }
        return sheet;

    }

‘

Can u tell what went Wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:53:51+00:00Added an answer on May 29, 2026 at 7:53 pm

    It seems that Add_value starts creating rows from top. Therefore on the second call the old rows are removed.

    Replace

             row = sheet.createRow(count);
    

    with

             row = k == 0 ? sheet.createRow(count) : sheet.getRow(count);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an Excel File using Apache POI. I want to write in
I'm using apache poi to create an excel document. To create new sheet in
I just started using the new POI 3.6 http://poi.apache.org XSSF which was released in
I'm using Apache POI 3.6, I want to read an excel file which has
I need some help in Apache poi I am generating excel using Apache POI
I need to display the newly generated excel (from tables using Apache POI) in
I'm generating an excel file using Apache POI 3.8 , and have the need
When trying to convert excel file to Html using org.apache.poi.ss.examples.html.ToHtml.create(...), the call crashes with
I am using Apache POI API to generate excel spreadsheet to output some data.
I've been using Apache POI for some time to read existing Excel 2003 files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.