mirror of https://github.com/apache/poi.git
Start on HSSF/XSSF Shrink To Fit support, see bug #55661
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1539848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3e91be2c5a
commit
9332cdcc18
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.usermodel;
|
package org.apache.poi.hssf.usermodel;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.hssf.model.InternalWorkbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
|
@ -807,6 +806,21 @@ public final class HSSFCellStyle implements CellStyle {
|
||||||
sr.setName(styleName);
|
sr.setName(styleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls if the Cell should be auto-sized
|
||||||
|
* to shrink to fit if the text is too long
|
||||||
|
*/
|
||||||
|
public void setShrinkToFit(boolean shrinkToFit) {
|
||||||
|
_format.setShrinkToFit(shrinkToFit);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Should the Cell be auto-sized by Excel to shrink
|
||||||
|
* it to fit if this text is too long?
|
||||||
|
*/
|
||||||
|
public boolean getShrinkToFit() {
|
||||||
|
return _format.getShrinkToFit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that this style belongs to the supplied Workbook.
|
* Verifies that this style belongs to the supplied Workbook.
|
||||||
* Will throw an exception if it belongs to a different one.
|
* Will throw an exception if it belongs to a different one.
|
||||||
|
|
|
@ -113,7 +113,7 @@ public interface CellStyle {
|
||||||
* dot border
|
* dot border
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final static short BORDER_HAIR = 0x7;
|
public final static short BORDER_HAIR = 0x7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thick border
|
* Thick border
|
||||||
|
@ -131,7 +131,7 @@ public interface CellStyle {
|
||||||
* hair-line border
|
* hair-line border
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final static short BORDER_DOTTED = 0x4;
|
public final static short BORDER_DOTTED = 0x4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Medium dashed border
|
* Medium dashed border
|
||||||
|
@ -701,4 +701,16 @@ public interface CellStyle {
|
||||||
* XSSFCellStyle)
|
* XSSFCellStyle)
|
||||||
*/
|
*/
|
||||||
public void cloneStyleFrom(CellStyle source);
|
public void cloneStyleFrom(CellStyle source);
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Controls if the Cell should be auto-sized
|
||||||
|
* to shrink to fit if the text is too long
|
||||||
|
*/
|
||||||
|
public void setShrinkToFit(boolean shrinkToFit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the Cell be auto-sized by Excel to shrink
|
||||||
|
* it to fit if this text is too long?
|
||||||
|
*/
|
||||||
|
public boolean getShrinkToFit();
|
||||||
|
}
|
|
@ -30,8 +30,8 @@ import org.apache.poi.xssf.model.StylesTable;
|
||||||
import org.apache.poi.xssf.model.ThemesTable;
|
import org.apache.poi.xssf.model.ThemesTable;
|
||||||
import org.apache.poi.xssf.usermodel.extensions.XSSFCellAlignment;
|
import org.apache.poi.xssf.usermodel.extensions.XSSFCellAlignment;
|
||||||
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
|
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
|
||||||
import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
|
|
||||||
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder.BorderSide;
|
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder.BorderSide;
|
||||||
|
import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
|
||||||
import org.apache.xmlbeans.XmlException;
|
import org.apache.xmlbeans.XmlException;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
|
||||||
|
@ -668,6 +668,11 @@ public class XSSFCellStyle implements CellStyle {
|
||||||
return (short)(align == null ? 0 : align.getTextRotation());
|
return (short)(align == null ? 0 : align.getTextRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getShrinkToFit() {
|
||||||
|
CTCellAlignment align = _cellXf.getAlignment();
|
||||||
|
return align != null && align.getShrinkToFit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the color to use for the top border
|
* Get the color to use for the top border
|
||||||
*
|
*
|
||||||
|
@ -1390,6 +1395,11 @@ public class XSSFCellStyle implements CellStyle {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShrinkToFit(boolean shrinkToFit) {
|
||||||
|
getCellAlignment().setShrinkToFit(shrinkToFit);
|
||||||
|
}
|
||||||
|
|
||||||
private int getFontId() {
|
private int getFontId() {
|
||||||
if (_cellXf.isSetFontId()) {
|
if (_cellXf.isSetFontId()) {
|
||||||
return (int) _cellXf.getFontId();
|
return (int) _cellXf.getFontId();
|
||||||
|
|
|
@ -16,19 +16,18 @@
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi.xssf.usermodel.extensions;
|
package org.apache.poi.xssf.usermodel.extensions;
|
||||||
|
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment;
|
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STHorizontalAlignment;
|
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignment;
|
|
||||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||||
import org.apache.poi.util.Internal;
|
import org.apache.poi.util.Internal;
|
||||||
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment;
|
||||||
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STHorizontalAlignment;
|
||||||
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignment;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cell settings avaiable in the Format/Alignment tab
|
* Cell settings available in the Format/Alignment tab
|
||||||
*/
|
*/
|
||||||
public class XSSFCellAlignment {
|
public class XSSFCellAlignment {
|
||||||
|
|
||||||
private CTCellAlignment cellAlignement;
|
private CTCellAlignment cellAlignement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,6 +157,14 @@ public class XSSFCellAlignment {
|
||||||
cellAlignement.setWrapText(wrapped);
|
cellAlignement.setWrapText(wrapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getShrinkToFit() {
|
||||||
|
return cellAlignement.getShrinkToFit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShrinkToFit(boolean shrink) {
|
||||||
|
cellAlignement.setShrinkToFit(shrink);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to low-level data
|
* Access to low-level data
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue