public class AddDimensionedImage {
// Four constants that determine how - and indeed whether - the rows
- // and columns an image may overlie should be expanded to accomodate that
+ // and columns an image may overlie should be expanded to accommodate that
// image.
// Passing EXPAND_ROW will result in the height of a row being increased
- // to accomodate the image if it is not already larger. The image will
+ // to accommodate the image if it is not already larger. The image will
// be layed across one or more columns.
// Passing EXPAND_COLUMN will result in the width of the column being
- // increased to accomodate the image if it is not already larger. The image
+ // increased to accommodate the image if it is not already larger. The image
// will be layed across one or many rows.
// Passing EXPAND_ROW_AND_COLUMN will result in the height of the row
// bing increased along with the width of the column to accomdate the
}
// Call methods to calculate how the image and sheet should be
- // manipulated to accomodate the image; columns and then rows.
+ // manipulated to accommodate the image; columns and then rows.
colClientAnchorDetail = this.fitImageToColumns(sheet, colNumber,
reqImageWidthMM, resizeBehaviour);
rowClientAnchorDetail = this.fitImageToRows(sheet, rowNumber,
}
/**
- * Determines whether the sheets columns should be re-sized to accomodate
+ * Determines whether the sheets columns should be re-sized to accommodate
* the image, adjusts the columns width if necessary and creates then
* returns a ClientAnchorDetail object that facilitates construction of
* an HSSFClientAnchor that will fix the image on the sheet and establish
colWidthMM = ConvertImageUnits.widthUnits2Millimetres(
(short)sheet.getColumnWidth(colNumber));
- // Check that the column's width will accomodate the image at the
+ // Check that the column's width will accommodate the image at the
// required dimension. If the width of the column is LESS than the
// required width of the image, decide how the application should
// respond - resize the column or overlay the image across one or more
}
/**
- * Determines whether the sheet's row should be re-sized to accomodate
+ * Determines whether the sheet's row should be re-sized to accommodate
* the image, adjusts the rows height if necessary and creates then
* returns a ClientAnchorDetail object that facilitates construction of
* an HSSFClientAnchor that will fix the image on the sheet and establish
// Get the row's height in millimetres
double rowHeightMM = row.getHeightInPoints() / ConvertImageUnits.POINTS_PER_MILLIMETRE;
- // Check that the row's height will accomodate the image at the required
+ // Check that the row's height will accommodate the image at the required
// dimensions. If the height of the row is LESS than the required height
// of the image, decide how the application should respond - resize the
// row or overlay the image across a series of rows.
public class AddDimensionedImage {
// Four constants that determine how - and indeed whether - the rows
- // and columns an image may overlie should be expanded to accomodate that
+ // and columns an image may overlie should be expanded to accommodate that
// image.
// Passing EXPAND_ROW will result in the height of a row being increased
- // to accomodate the image if it is not already larger. The image will
+ // to accommodate the image if it is not already larger. The image will
// be layed across one or more columns.
// Passing EXPAND_COLUMN will result in the width of the column being
- // increased to accomodate the image if it is not already larger. The image
+ // increased to accommodate the image if it is not already larger. The image
// will be layed across one or many rows.
// Passing EXPAND_ROW_AND_COLUMN will result in the height of the row
// bing increased along with the width of the column to accomdate the
}
// Call methods to calculate how the image and sheet should be
- // manipulated to accomodate the image; columns and then rows.
+ // manipulated to accommodate the image; columns and then rows.
colClientAnchorDetail = this.fitImageToColumns(sheet, colNumber,
reqImageWidthMM, resizeBehaviour);
rowClientAnchorDetail = this.fitImageToRows(sheet, rowNumber,
colWidthMM = ConvertImageUnits.widthUnits2Millimetres(
(short)sheet.getColumnWidth(colNumber));
- // Check that the column's width will accomodate the image at the
+ // Check that the column's width will accommodate the image at the
// required dimension. If the width of the column is LESS than the
// required width of the image, decide how the application should
// respond - resize the column or overlay the image across one or more
}
/**
- * Determines whether the sheets row should be re-sized to accomodate
+ * Determines whether the sheets row should be re-sized to accommodate
* the image, adjusts the rows height if necessary and creates then
* returns a ClientAnchorDetail object that facilitates construction of
* a ClientAnchor that will fix the image on the sheet and establish
// Get the row's height in millimetres
rowHeightMM = row.getHeightInPoints() / ConvertImageUnits.POINTS_PER_MILLIMETRE;
- // Check that the row's height will accomodate the image at the required
+ // Check that the row's height will accommodate the image at the required
// dimensions. If the height of the row is LESS than the required height
// of the image, decide how the application should respond - resize the
// row or overlay the image across a series of rows.
cs.setWrapText(true);
cell.setCellStyle(cs);
- //increase row height to accomodate two lines of text
- row.setHeightInPoints((2 * sheet.getDefaultRowHeightInPoints()));
+ //increase row height to accommodate two lines of text
+ row.setHeightInPoints(2 * sheet.getDefaultRowHeightInPoints());
//adjust column width to fit the content
sheet.autoSizeColumn(2);
}
}
}
-
}
private int hStart = -1;
private int hLen;
+ @Override
public String handlePart(Matcher m, String part, CellFormatType type,
StringBuffer desc) {
==================================================================== */
package org.apache.poi.ss.format;
-import org.apache.poi.ss.format.CellFormatPart.PartHandler;
-
import java.util.Locale;
-import java.util.regex.Matcher;
/**
* This class implements printing out text.
final int[] numPlaces = new int[1];
desc = CellFormatPart.parseFormat(format, CellFormatType.TEXT,
- new PartHandler() {
- public String handlePart(Matcher m, String part,
- CellFormatType type, StringBuffer desc) {
- if (part.equals("@")) {
- numPlaces[0]++;
- return "\u0000";
- }
- return null;
+ (m, part, type, desc) -> {
+ if (part.equals("@")) {
+ numPlaces[0]++;
+ return "\u0000";
}
+ return null;
}).toString();
// Remember the "@" positions in last-to-first order (to make insertion easier)
text = text.toUpperCase(Locale.ROOT);
}
toAppendTo.append(desc);
- for (int i = 0; i < textPos.length; i++) {
- int pos = start + textPos[i];
+ for (int textPo : textPos) {
+ int pos = start + textPo;
toAppendTo.replace(pos, pos + 1, text);
}
}
/**
* YK: subclasses of RefPtgBase are used by the FormulaParser and FormulaEvaluator accross HSSF and XSSF.
- * The bit mask should accomodate the maximum number of avaiable columns, i.e. 0x3FFF.
+ * The bit mask should accommodate the maximum number of avaiable columns, i.e. 0x3FFF.
*
* @see org.apache.poi.ss.SpreadsheetVersion
*/
}
/**
- * Utility method that returns the named short value form the given map.
+ * Utility method that returns the named short value from the given map.
*
* @param properties map of named properties (String -> Object)
* @param name property name
}
/**
- * Utility method that returns the named int value form the given map.
+ * Utility method that returns the named int value from the given map.
*
* @param properties map of named properties (String -> Object)
* @param name property name
}
/**
- * Utility method that returns the named BorderStyle value form the given map.
+ * Utility method that returns the named BorderStyle value from the given map.
*
* @param properties map of named properties (String -> Object)
* @param name property name
}
/**
- * Utility method that returns the named FillPatternType value form the given map.
+ * Utility method that returns the named FillPatternType value from the given map.
*
* @param properties map of named properties (String -> Object)
* @param name property name
}
/**
- * Utility method that returns the named HorizontalAlignment value form the given map.
+ * Utility method that returns the named HorizontalAlignment value from the given map.
*
* @param properties map of named properties (String -> Object)
* @param name property name
}
/**
- * Utility method that returns the named VerticalAlignment value form the given map.
+ * Utility method that returns the named VerticalAlignment value from the given map.
*
* @param properties map of named properties (String -> Object)
* @param name property name
}
/**
- * Utility method that returns the named boolean value form the given map.
+ * Utility method that returns the named boolean value from the given map.
*
* @param properties map of properties (String -> Object)
* @param name property name
}
return false;
}
-
+
/**
* Utility method that puts the given value to the given map.
*
cell.setCellStyle(style);
// Everything is fine at this point, cell is red
+ XSSFColor actual = cell.getCellStyle().getFillBackgroundColorColor();
+ assertNull(actual);
+ actual = cell.getCellStyle().getFillForegroundColorColor();
+ assertNotNull(actual);
+ assertEquals(color.getARGBHex(), actual.getARGBHex());
Map<String, Object> properties = new HashMap<>();
properties.put(CellUtil.BORDER_BOTTOM, BorderStyle.THIN);
CellUtil.setCellStyleProperties(cell, properties);
// Now the cell is all black
- XSSFColor actual = cell.getCellStyle().getFillBackgroundColorColor();
+ actual = cell.getCellStyle().getFillBackgroundColorColor();
+ assertNotNull(actual);
+ assertNull(actual.getARGBHex());
+ actual = cell.getCellStyle().getFillForegroundColorColor();
assertNotNull(actual);
assertEquals(color.getARGBHex(), actual.getARGBHex());