当前位置: 首页>>代码示例>>Java>>正文


Java NumberFormat类代码示例

本文整理汇总了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();
	}
 
开发者ID:tesis-dynaware,项目名称:fancy-chart,代码行数:29,代码来源:XlsDao.java

示例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;
}
 
开发者ID:micromagic,项目名称:eterna,代码行数:30,代码来源:ExportExcelExecute.java

示例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()));
            }
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo-extensions,代码行数:18,代码来源:InMemorySpreadsheet.java

示例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);
}
 
开发者ID:vagfed,项目名称:hmcScanner,代码行数:7,代码来源:Loader.java


注:本文中的jxl.write.NumberFormat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。