package org.apache.poi.hssf.usermodel;
-import java.util.Arrays;
import java.util.List;
import org.apache.poi.hssf.model.InternalWorkbook;
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.
* Will throw an exception if it belongs to a different one.
* dot border
*/
- public final static short BORDER_HAIR = 0x7;\r
+ public final static short BORDER_HAIR = 0x7;
/**
* Thick border
* hair-line border
*/
- public final static short BORDER_DOTTED = 0x4;\r
+ public final static short BORDER_DOTTED = 0x4;
/**
* Medium dashed border
* XSSFCellStyle)
*/
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();
+}
\ No newline at end of file
import org.apache.poi.xssf.model.ThemesTable;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellAlignment;
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.XSSFCellFill;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
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
*
break;
}
}
+
+ public void setShrinkToFit(boolean shrinkToFit) {
+ getCellAlignment().setShrinkToFit(shrinkToFit);
+ }
+
private int getFontId() {
if (_cellXf.isSetFontId()) {
return (int) _cellXf.getFontId();
==================================================================== */
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.VerticalAlignment;
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 {
-
private CTCellAlignment cellAlignement;
/**
cellAlignement.setWrapText(wrapped);
}
+ public boolean getShrinkToFit() {
+ return cellAlignement.getShrinkToFit();
+ }
+
+ public void setShrinkToFit(boolean shrink) {
+ cellAlignement.setShrinkToFit(shrink);
+ }
+
/**
* Access to low-level data
*/