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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:52:02+00:00 2026-05-28T06:52:02+00:00

I am using one HSSF Workbook as a template for another. Because of how

  • 0

I am using one HSSF Workbook as a template for another. Because of how that works, as you probably know if you’re reading this, I cannot simply take a cell from workbook 1 and set its style to the CellStyle from workbook 2. The way this is supposed to be done is to cloneStyleFrom the second style.

However, there is a maximum of 4000 styles in a worksheet so I am trying to avoid cloning an unlimited number of styles. So, I am checking to see if a the style I am about to clone is equal to any style that already exists in my workbook. If it is, I just use the style that already exists. If it isn’t, I clone the style from the template workbook.

I’m using the equals method defined below, which doesn’t seem to care what workbook the style comes from.

http://www.java2s.com/Open-Source/Java-Document/Collaboration/poi-3.6/org/apache/poi/hssf/usermodel/HSSFCellStyle.java.htm#equalsObject

However, when at the end of all this I check:

        if ( !getCellStyle().equals(cell.getCellStyle()) ) {
            System.out.println("Not equal to cloned style!");
        } else {
            System.out.println("Equal to cloned style.");
        }

… the output indicates that the styles are not equal.

Why is this?

Note: Verified that both objects are type HSSFCellStyle using instanceof.

  • 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-28T06:52:03+00:00Added an answer on May 28, 2026 at 6:52 am

    I had a look into the equals method.
    If everything is equal the _index variable will be checked.
    It seems, that the index is dependend on the position in a list of ExtendedFormat objects (s. Javadoc below).
    If the the HSSFCellStyle contains information about a position and serves as a wrapper for ExtendedFormatRecord, maybe you could reuse the ExtendedFormatRecord object to conserve space.

    /**
             * get the index within the HSSFWorkbook (sequence within the collection of ExtnededFormat objects)
             * @return unique index number of the underlying record this style represents (probably you don't care
             *  unless you're comparing which one is which)
             */
            public short getIndex() {
                return _index;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i am using one string to another class. Actually i know we have
When using one of the various JDBC template methods I am confused on how
I am using one master page.In that I am registering java scripts and checking
I'm using one of the examples for the v4 compatibility app. I've noticed that
I using one header control in wpf application in that I am using Grid
I'm having trouble using one Lua lib from inside another. I'm not sure about
Usually I'm using One-to-many relationship by this way : class Study { static hasMany
I am using one template to build my web site. I want to add
Hi I am using one label that displays question & radiobuttonlist for answers. when
i am using one tree view control in asp.net, in this tree view i

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.