public class ExcelTools extends Object implements Serializable
ByteTools,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static String[] |
ALPHASDELETE |
| Constructor and Description |
|---|
ExcelTools() |
| Modifier and Type | Method and Description |
|---|---|
static void |
benchmark(String info,
Object perfobj)
tracks minimal info container for counters -> start time, last time,
start mem, last mem
|
static String |
formatLocation(int[] rowCol)
Takes an int array representing a row and column and formats it as a cell
address.
|
static String |
formatLocation(int[] s,
boolean bRelRow,
boolean bRelCol)
Takes an int array representing a row and column and formats it as a cell
address, taking into account relative or absolute refs
The index is zero-based.
|
static String |
formatNumericNotation(String num,
int notationType)
Formats a string representation of a numeric value as a string in the
specified notation:
|
static String |
formatRange(int[] s)
Takes an array of four shorts and formats it as a cell range.
|
static String |
formatRangeRowCol(int[] s)
format a range as a string, range in format of [r][c][r1][c1]
|
static String |
formatRangeRowCol(int[] s,
boolean[] bRelAddresses)
format a range as a string, range in format of [r][c][r1][c1] including
relative address state
|
static String |
getAlphaVal(int i)
get the Excel-style Column alphabetical representation of an integer
(0-based).
|
static CellHandle[] |
getCellHandlesFromSheet(String strRange,
WorkSheetHandle sheet)
Return an array of cell handles specified from the string passed in.
|
static String |
getFormattedStringVal(Object o,
String pattern)
static version of getFormattedStringVal; given an object value, a
valid Excel format pattern, return the formatted string value.
|
static int |
getIntVal(String c)
get the int value of the Excel-style Column alpha representation.
|
static String |
getLogDate()
get recordy byte def as a String
public static String getRecordByteDef(XLSRecord rec){ byte[] b =
rec.read(); StringBuffer sb = new StringBuffer("byte[] rbytes = {");
for(int t = 0;t |
static String |
getNumberAsString(double fpnum)
Formats a double in the standard OpenXLS (General) format.
|
static Object |
getObject(Object in)
Takes an input Object and attempts to convert to numeric Objects of the
highest precision possible.
|
static float |
getPixels(float twips)
convert twips to pixels
In addition to a calculated size unit derived from the average size of
the default characters 0-9, Excel uses the 'twips' measurement which is
defined as:
1 twip = 1/20 point or 20 twips = 1 point 1 twip = 1/567 centimeter or
567 twips = 1 centimeter 1 twip = 1/1440 inch or 1440 twips = 1 inch
1 pixel = 0.75 points 1 pixel * 1.3333 = 1 point 1 twip * 20 = 1 point
|
static int[] |
getRangeCoords(String range)
return the first and last coords of a range in int form + the number of
cells in the range range is in the format of Sheet
|
static int[] |
getRangeRowCol(String range)
Parses an Excel cell range and returns the addresses as an int array.
|
static int[] |
getRowColFromString(String address)
Parses an Excel cell address into row and column integers.
|
static float |
getTwips(float pixels)
convert pixels to twips
In addition to a calculated size unit derived from the average size of
the default characters 0-9, Excel uses the 'twips' measurement which is
defined as:
1 pixel = 0.75 points 1 pixel * 1.3333 = 1 point 1 twip * 20 = 1 point
|
static boolean |
intersects(String rng,
int[] rc)
returns true if range intersects with range2
|
static boolean |
isAfterRange(int[] rc,
int[] rng)
returns true if address is before the range coordinates defined by rc
|
static boolean |
isBeforeRange(int[] rc,
int[] rng)
returns true if address is before the range coordinates defined by rc
|
static boolean |
isInRange(String rng,
int rowFirst,
int rowLast,
int colFirst,
int colLast)
A FAIL FAST implementation for finding whether a cell string address
falls within a set of row/col range coordinates.
|
static String[] |
stripSheetNameFromRange(String address)
Strip sheet name(s) from range string can be Sheet1!AB:Sheet!BC or
Sheet!AB:BC or AB:BC or Sheet1:Sheet2!A1:A2
|
static int[] |
transformStringToIntVals(String trans)
Transforms a string to an array of ints for evaluation purposes.
|
public static final String[] ALPHASDELETE
public static String getNumberAsString(double fpnum)
fpnum - public static String getFormattedStringVal(Object o, String pattern)
Object - oString - pattern if General or "" returns string valueboolean - isInteger if General pattern, attempt to use integer value (rather than double)public static boolean isInRange(String rng, int rowFirst, int rowLast, int colFirst, int colLast)
rng - the range you want to testrowFirst - in the target rangerowLast - in the target rangecolFirst - in the target rangecolLast - in the target rangepublic static boolean intersects(String rng, int[] rc)
rng - rc - public static boolean isBeforeRange(int[] rc,
int[] rng)
rc - row col of addressrng - int[] coordinates as: row0, col0, row1, col1public static boolean isAfterRange(int[] rc,
int[] rng)
rc - row col of addressrng - int[] coordinates as: row0, col0, row1, col1public static Object getObject(Object in)
input - public static final float getPixels(float twips)
pixels - public static final float getTwips(float pixels)
pixels - public static String getLogDate()
public static void benchmark(String info, Object perfobj)
info - perfobj - public static String getAlphaVal(int i)
public static int getIntVal(String c)
String - column namepublic static int[] getRowColFromString(String address)
address - the address to parse, either A1 or R1C1IllegalArgumentException - if the argument is not a valid addresspublic static int[] getRangeRowCol(String range)
stripSheetNameFromRange(java.lang.String) before calling this method. If the
argument is a single cell address it will be returned for both bounds.range - the range to parseIllegalArgumentException - if the addresses are invalidpublic static String formatLocation(int[] rowCol)
int[] - the numeric range to convertpublic static String formatLocation(int[] s, boolean bRelRow, boolean bRelCol)
int[] - the numeric range to convertbRelRow - if true, no "$"s are added, relative row referencebRelCol - if true, no "$"s are added, relative col referencepublic static String formatRange(int[] s)
int[] - the numeric range to convertpublic static String formatRangeRowCol(int[] s)
s - public static String formatRangeRowCol(int[] s, boolean[] bRelAddresses)
s - bRelAddresses - contains relative row and col state for each rcr1c1public static int[] transformStringToIntVals(String trans)
public static String formatNumericNotation(String num, int notationType)
int - public static CellHandle[] getCellHandlesFromSheet(String strRange, WorkSheetHandle sheet)
cellstr - - a comma delimited String representing cells and cell ranges,
example "A1,A5,A6,B1:B5" would return cells A1, A5, A6, B1,
B2, B3, B4, B5sheet - the worksheet containing the cells.public static String[] stripSheetNameFromRange(String address)
address - or range Stringpublic static int[] getRangeCoords(String range)
Copyright © 2002–2019 Starter Inc.. All rights reserved.