You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Avik Sengupta <av...@itellix.com> on 2003/08/25 20:00:02 UTC

Re: 'NO IDEA SHARED FORMULA EXP PTG' appears when read copy/paste formula HSSF

Joji,

OK, here goes

Shared formula records are stored as one  Formula and SharedFormula record for the first cell in a range, and then FormulaRecords with an ExpPtg for all other cells that just reference the original record.  

The creation of the correct string happens in 
public String toFormulaString(Workbook book) in o.a.p.record.formula.ExpPtg.java

You have to find a reference to the FormulaRecordAggregate out of the book, from which you will get the FormulaRecord and the SharedFormulaRecord (thats the very difficult bit.. will require some thinking, since hackish solutions will not be committed..) . You will then have to do a toFormulaString on the formula record, but you will have to make an allowance for the range difference ie, the the formula record will be for A1, but if you are in A10, you will have to change the relative references. For this last  bit, you might have to refactor the Reference code .. which is duplicated unfortunately at two places... (so this is the slightly difficult bit)

To do all this, the first thing you need to do is read the specs, either in the excel book (if you have it... if you are in Bangalore, i can lend it you for some time....) , or in the OpenOffice documentation..

Hope that helps. This is something we really need to do, so it would be great if you could help. 

Shout if you need anything else. 

Regards
-
Avik

PS. If you are doing this, once you have a better fix on what needs to be done, lets discuss on the list whether to do it for 2.0 or 3.0



   -------Original Message-------
   &gt; From: Danny Mui &lt;danny@muibros.com&gt;
   &gt; Subject: Re: Bugzilla Bug 20321 'NO IDEA SHARED FORMULA EXP PTG' appears when read copy/paste formula  HSSF
   &gt; Sent: 25 Aug 2003 21:04:38
   &gt;
   &gt;  The write way to fix this is to undo the &quot;optimization&quot; of the shared
   &gt;  formula.  Instead of referencing an EXP ptg, we should expand the
   &gt;  formula in full when reading the file (sheet.fillfields).  My first cut
   &gt;  with shared formulas was to just allow it to be read.  Didn't realize
   &gt;  people messed with the shared formula fields.
   &gt;  
   &gt;  Having the Excel Developer's SDK book is a real help for doing this but
   &gt;  using the BiffViewer and reading hex dumps can work as well.
   &gt;  
   &gt;  Joji John wrote:
   &gt;  
   &gt;  &gt;
   &gt;  &gt;
   &gt;  &gt;Yes, The problem is excatly what you are describing. I would like to know
   &gt;  &gt;if I can work with somebody to fix this problem and thus contribute to this
   &gt;  &gt;project. I require some directions to fix this bug.
   &gt;  &gt;
   &gt;  &gt;Thanks and Regards,
   &gt;  &gt;Joji John,
   &gt;  &gt;
   &gt;  &gt;
   &gt;  &gt;
   &gt;  &gt;                                                                                                          
   &gt;  &gt;                      Danny Mui                                                                            
   &gt;  &gt;                                            m&gt;                       cc:                                                        
   &gt;  &gt;                                               Subject:  Re: Bugzilla Bug 20321 &quot;NO IDEA SHARED FORMULA    
   &gt;  &gt;                      08/22/2003 10:15          EXP PTG&quot; appears when read copy/paste formula  HSSF        
   &gt;  &gt;                      PM                                                                                  
   &gt;  &gt;                      Please respond to                                                                    
   &gt;  &gt;                      &quot;POI Developers                                                                      
   &gt;  &gt;                      List&quot;                                                                                
   &gt;  &gt;                                                                                                          
   &gt;  &gt;                                                                                                          
   &gt;  &gt;
   &gt;  &gt;
   &gt;  &gt;
   &gt;  &gt;The bug in question occurs when you try to modify a cell in the
   &gt;  &gt;copy/pasted formula group.  If you're simply reading/writing AROUND
   &gt;  &gt;these cells you should be fine.  In the future we should break up the
   &gt;  &gt;shared formula to be regular formulas.
   &gt;  &gt;
   &gt;  &gt;If this isn't what you're doing, please submit a new bug report with
   &gt;  &gt;example code (simplest amount of code possible) and the excel file that
   &gt;  &gt;duplicates this problem.
   &gt;  &gt;
   &gt;  &gt;Joji John wrote:
   &gt;  &gt;
   &gt;  &gt;  
   &gt;  &gt;
   &gt;  &gt;&gt;
   &gt;  &gt;&gt;Hi,
   &gt;  &gt;&gt;I am using HSSF to read microsoft excel files. Now, we have a situation
   &gt;  &gt;&gt;same as the one  described in Bug # 20321. I had taken the latest poi jar
   &gt;  &gt;&gt;file poi-bin-2.0-pre3-20030728.zip  updated at  28-Jul-2003 11:56 and
   &gt;  &gt;&gt;    
   &gt;  &gt;&gt;
   &gt;  &gt;found
   &gt;  &gt;  
   &gt;  &gt;
   &gt;  &gt;&gt;the problem persisting. Do we have some information on any possible fix to
   &gt;  &gt;&gt;this defect?
   &gt;  &gt;&gt;
   &gt;  &gt;&gt;Thanks and Regards,
   &gt;  &gt;&gt;Joji John,
   &gt;  &gt;&gt;IBM Software Labs,
   &gt;  &gt;&gt;Airport Road,
   &gt;  &gt;&gt;Bangalore 560 017
   &gt;  &gt;&gt;Phone: 91 80 5044974
   &gt;  &gt;&gt;Email: jjoji@in.ibm.com
   &gt;  &gt;&gt;
   &gt;  &gt;&gt;
   &gt;  &gt;&gt;
   &gt;  &gt;&gt;---------------------------------------------------------------------
   &gt;  &gt;&gt;To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
   &gt;  &gt;&gt;For additional commands, e-mail: poi-dev-help@jakarta.apache.org
   &gt;  &gt;&gt;
   &gt;  &gt;&gt;
   &gt;  &gt;&gt;
   &gt;  &gt;&gt;    
   &gt;  &gt;&gt;
   &gt;  &gt;
   &gt;  &gt;
   &gt;  &gt;---------------------------------------------------------------------
   &gt;  &gt;To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
   &gt;  &gt;For additional commands, e-mail: poi-dev-help@jakarta.apache.org
   &gt;  &gt;
   &gt;  &gt;
   &gt;  &gt;
   &gt;  &gt;
   &gt;  &gt;
   &gt;  &gt;---------------------------------------------------------------------
   &gt;  &gt;To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
   &gt;  &gt;For additional commands, e-mail: poi-dev-help@jakarta.apache.org
   &gt;  &gt;
   &gt;  &gt;  
   &gt;  &gt;
   &gt;  
   &gt;  
   &gt;  ---------------------------------------------------------------------
   &gt;  To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
   &gt;  For additional commands, e-mail: poi-dev-help@jakarta.apache.org
   -------Original Message-------