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 7561971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:17:49+00:00 2026-05-30T13:17:49+00:00

I’m generating an excel file using Apache POI 3.8 , and have the need

  • 0

I’m generating an excel file using Apache POI 3.8 , and have the need to replicate some existing row n° times.

This because I have some complex formula which I use as a template to create new lines, replacing cell indexes with regexps.

The problem is that performance are awful, it takes 2h to generate some 4000 rows.

I’ve pinpointed the problem to be not in the regexp part, as I initially thought, but in the duplication of formula cells.

I actually use this to replicate formula cells:

case Cell.CELL_TYPE_FORMULA:
    newCell.setCellType(oldCell.getCellType());
    newCell.setCellFormula(oldCell.getCellFormula());
    break; 

If I copy the formula as text like this:

case Cell.CELL_TYPE_FORMULA:
    newCell.setCellType(Cell.CELL_TYPE_STRING);
    newCell.setCellValue("="+oldCell.getCellFormula());
    break;

it’s instead pretty fast, even with my regexp in place.

Anyway, this is an imperfect solution, because the formula has english keywords (ie IF()), when I need to write in italian format.

More, cells with formula inserted like that need to be forcefully re-evaluated in excel with something like “replace all -> ‘=’ with ‘='”.

The problem seems to rely in the setCellFormula(), because of the HSSFFormulaParser.parse().

What’s strange, is that parsing time seems to grow exponentially:

100 rows ->  6785ms
200 rows -> 23933ms
300 rows -> 51388ms
400 rows -> 88586ms

What it seems, is that each time I copy a formula, the POI library re-evaluates or re-parses or re-something all preceding rows.

Do anyone know how can solve this problem?
Thanks in advance.

  • 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-30T13:17:51+00:00Added an answer on May 30, 2026 at 1:17 pm

    Oh my…I think I found it…

    Original was:

    // If the row exist in destination, push down all rows by 1 else create a new row
    if (newRow != null) {
        worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1);
    } else {
        newRow = worksheet.createRow(destinationRowNum);
    }
    

    I’ve commented everything leaving only

    newRow = worksheet.createRow(destinationRowNum);
    

    And now I’m down to 60sec to process all rows!

    Probably, there’s some dirt in my template which was causing POI to shift everything at each iteration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.