You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2013/10/17 13:16:43 UTC

[Bug 55661] New: Support for option "shrink to fit"

https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

            Bug ID: 55661
           Summary: Support for option "shrink to fit"
           Product: POI
           Version: 3.9
          Hardware: PC
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: ofra@ivu.de

Hi,
excel provides the option "shrink to fit" for a cell, which autosizes the
content of the cell, if it is too long.
Unfortunately it is not possible to set this option using POI.

Since the class
"org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment" already
supports this option, the necessessary enhancement should be quite simple.
I just need the following methods in XSSFCellStyle:

public void setShrinkToFit(boolean shrinkToFit) {
    getCellAlignment().setShrinkToFit(shrinkToFit);
}

public boolean getShrinkToFit() {
    CTCellAlignment align = _cellXf.getAlignment();
    return align != null && align.isSetShrinkToFit();
}

Regards
Oliver

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #10 from Nick Burch <ap...@gagravarr.org> ---
Thanks for your investigations, and test files

I've added support in r1539848, along with unit tests for it in r1539850.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

--- Comment #5 from Oliver Frank <of...@ivu.de> ---
I've created both test files (with and without shrink to fit) and diffed the
output of BiffViewer. Unfortunately there are 275 differences between them.
But in the output for the file with shrink to fit a found the entry
".shrinktoft= true" in line 3475. I hope/guess this is the important difference
between these files.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

--- Comment #3 from Nick Burch <ap...@gagravarr.org> ---
If you have some time, any chance you could create two very similar and simple
.xls files? Firstly create one without shrink to fit, then open the same file +
set shrink to fit + save-as. (Should help ensure they're very similar). Then,
run org.apache.poi.hssf.dev.BiffViewer against the two, and diff the output.
With any luck, that will flag up the record that gets changed, along with the
option to do it!

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

Oliver Frank <of...@ivu.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #8 from Nick Burch <ap...@gagravarr.org> ---
(In reply to Oliver Frank from comment #5)
>  for the file with shrink to fit a found the entry
> ".shrinktoft= true" in line 3475.

That looks very likely to be what we need! Which record does this live in?
(Should be a few lines about that in the output)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

--- Comment #2 from Oliver Frank <of...@ivu.de> ---
Created attachment 30956
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30956&action=edit
Test file containing the option "shrink to fit"

Excel supports this for .xls files too. I've added a test document which
contains a cell with this option.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

lsj8080 <ls...@yeah.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #4 from lsj8080 <ls...@yeah.net> ---
Hi POI developer,
excel provides the option "shrink to fit" for a cell, which autosizes the
content of the cell, if it is too long in version 3.7. but I can't find the
method 'setShrinkToFit' in class "org.apache.poi.hssf.usermodel.HSSFCellStyle"
at version 3.9.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

--- Comment #7 from Oliver Frank <of...@ivu.de> ---
Created attachment 30968
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30968&action=edit
The output of BiffViewer for a file with shrink to fit

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

--- Comment #9 from Oliver Frank <of...@ivu.de> ---
Here is the record, in which this line occurs:
Offset=0x00000C9A(3226) recno=114 sid=0x00E0 size=0x0014(20)
[EXTENDEDFORMAT]
 CELL_RECORD_TYPE
    .fontindex       = 0
    .formatindex     = 0
    .celloptions     = 1
          .islocked  = true
          .ishidden  = false
          .recordtype= 0
          .parentidx = 0
    .alignmentoptions= 20
          .alignment = 0
          .wraptext  = false
          .valignment= 2
          .justlast  = 0
          .rotation  = 0
    .indentionoptions= 1010
          .indent    = 0
          .shrinktoft= true
          .mergecells= false
          .readngordr= 0
          .formatflag= false
          .fontflag  = false
          .prntalgnmt= true
          .borderflag= false
          .paternflag= false
          .celloption= false
    .borderoptns     = 0
          .lftln     = 0
          .rgtln     = 0
          .topln     = 0
          .btmln     = 0
    .paleteoptns     = 0
          .leftborder= 0
          .rghtborder= 0
          .diag      = 0
    .paleteoptn2     = 2000000
          .topborder = 0
          .botmborder= 0
          .adtldiag  = 0
          .diaglnstyl= 0
          .fillpattrn= 0
    .fillpaloptn     = 20c0
          .foreground= 40
          .background= 41
[/EXTENDEDFORMAT]

Does this contain the information, that you need?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
Does Excel support this for .xls files, or is it .xlsx only?

(That would affect if we need to put it on the interface or not, and if we
therefore need to get a test .xls file to identify the record there)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55661] Support for option "shrink to fit"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55661

--- Comment #6 from Oliver Frank <of...@ivu.de> ---
Created attachment 30967
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30967&action=edit
The output of BiffViewer for a file without shrink to fit

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org