本文整理汇总了Java中jxl.write.NumberFormat类的典型用法代码示例。如果您正苦于以下问题:Java NumberFormat类的具体用法?Java NumberFormat怎么用?Java NumberFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NumberFormat类属于jxl.write包,在下文中一共展示了NumberFormat类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importXls
import jxl.write.NumberFormat; //导入依赖的package包/类
public static SortedMap<java.lang.Number, java.lang.Number> importXls(String filePath) {
File inputWorkbook = new File(filePath);
try {
Workbook w = Workbook.getWorkbook(inputWorkbook);
// Get the first sheet
Sheet sheet = w.getSheet(0);
SortedMap<java.lang.Number, java.lang.Number> data = new TreeMap<>();
for (int i = 0; i < sheet.getRows(); i++) {
Cell xCell = sheet.getCell(0, i);
Cell yCell = sheet.getCell(1, i);
CellType xType = xCell.getType();
CellType yType = yCell.getType();
if (CellType.NUMBER.equals(xType) && CellType.NUMBER.equals(yType)) {
java.lang.Number key = java.text.NumberFormat.getNumberInstance(LOCALE).parse(xCell.getContents());
java.lang.Number value = java.text.NumberFormat.getNumberInstance(LOCALE)
.parse(yCell.getContents());
data.put(key, value);
}
}
return data;
} catch (BiffException | IOException | ParseException exception) {
exception.printStackTrace();
}
return Collections.emptySortedMap();
}
示例2: createFormat
import jxl.write.NumberFormat; //导入依赖的package包/类
protected jxl.write.WritableCellFormat createFormat(String format, String type, Map formatsMap,
jxl.write.WritableCellFormat defaultCF, WritableFont font)
throws WriteException
{
jxl.write.WritableCellFormat tmp = (jxl.write.WritableCellFormat) formatsMap.get(format);
if (tmp != null)
{
return tmp;
}
if ("number".equals(type))
{
NumberFormat nf = new NumberFormat(format);
tmp = new jxl.write.WritableCellFormat(font, nf);
tmp.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
tmp.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
formatsMap.put(format, tmp);
return tmp;
}
else if ("date".equals(type))
{
DateFormat df = new DateFormat(format);
tmp = new jxl.write.WritableCellFormat(font, df);
tmp.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
tmp.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
formatsMap.put(format, tmp);
return tmp;
}
return defaultCF;
}
示例3: setNumberCellValue
import jxl.write.NumberFormat; //导入依赖的package包/类
public void setNumberCellValue(final Number aCellValue, final String aPattern) {
if (aCellValue != null) {
if (aPattern != null) {
final DisplayFormat tmpDisplayFormat = new NumberFormat(aPattern);
final CellFormat tmpCellFormat = new WritableCellFormat(tmpDisplayFormat);
this.setCell(new jxl.write.Number(myColumn, myRow, aCellValue.doubleValue(), tmpCellFormat));
} else {
this.setCell(new jxl.write.Number(myColumn, myRow, aCellValue.doubleValue()));
}
}
}
示例4: formatPerc
import jxl.write.NumberFormat; //导入依赖的package包/类
private WritableCellFormat formatPerc(int map) throws WriteException {
NumberFormat cuspercent = new NumberFormat("0.00%");
WritableCellFormat wcf = new WritableCellFormat (cuspercent);;
return setParam(wcf,map);
}