本文整理汇总了Java中jxl.write.Number类的典型用法代码示例。如果您正苦于以下问题:Java Number类的具体用法?Java Number怎么用?Java Number使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Number类属于jxl.write包,在下文中一共展示了Number类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addNumber
import jxl.write.Number; //导入依赖的package包/类
private void addNumber(WritableSheet sheet, int col, int row, String s[], int index, WritableCellFormat format) throws RowsExceededException, WriteException {
if (sheet==null || s==null)
return;
if (index>=s.length)
return;
double d;
try {
d = Double.parseDouble(s[index]);
// Only keep 2 digits: avoid rounding errors
d = 1d*(int)(d*100)/100;
sheet.addCell(new Number(col,row,d,format));
} catch (NumberFormatException nfe) {}
}
示例2: addNumberDiv1024
import jxl.write.Number; //导入依赖的package包/类
private void addNumberDiv1024(WritableSheet sheet, int col, int row, String s[], int index, WritableCellFormat format) throws RowsExceededException, WriteException {
if (sheet==null || s==null)
return;
if (index>=s.length)
return;
double d;
try {
d = Double.parseDouble(s[index]);
d = d / 1024;
// Only keep 2 digits: avoid rounding errors
d = 1d*(int)(d*100)/100;
sheet.addCell(new Number(col,row,d,format));
} catch (NumberFormatException nfe) {}
}
示例3: writeRecord
import jxl.write.Number; //导入依赖的package包/类
@Override
public void writeRecord(final Record record) throws IOException, WriteException {
int index = 0;
List<String> row = exportService.createRow(record);
if (row != null) {
for (String cell: row) {
if (cell == null || cell.trim().length() < 1) {
sheet.addCell(new Label(index++, rowCount, ""));
} else if (cell.matches("-?\\d+(\\.\\d+)?")) { // match number with optional '-' and decimal
sheet.addCell(new Number(index++, rowCount, Double.parseDouble(cell)));
} else {
sheet.addCell(new Label(index++, rowCount, cell));
}
}
rowCount++;
}
}
示例4: exportXls
import jxl.write.Number; //导入依赖的package包/类
public static void exportXls(SortedMap<java.lang.Number, java.lang.Number> data, String filePath) {
File file = new File(filePath);
WorkbookSettings workBookSettings = new WorkbookSettings();
workBookSettings.setLocale(LOCALE);
try {
WritableWorkbook workbook = Workbook.createWorkbook(file, workBookSettings);
workbook.createSheet("Exported data", 0);
WritableSheet sheet = workbook.getSheet(0);
fillSheet(sheet, data);
workbook.write();
workbook.close();
} catch (IOException | WriteException exception) {
System.err.println(exception.getMessage());
}
}
示例5: MulRKRecord
import jxl.write.Number; //导入依赖的package包/类
/**
* Constructs the rk numbers from the integer cells
*
* @param numbers A list of jxl.write.Number objects
*/
public MulRKRecord(List numbers)
{
super(Type.MULRK);
row = ((Number)numbers.get(0)).getRow();
colFirst = ((Number)numbers.get(0)).getColumn();
colLast = colFirst + numbers.size() - 1;
rknumbers = new int[numbers.size()];
xfIndices = new int[numbers.size()];
for (int i = 0; i < numbers.size(); i++)
{
rknumbers[i] = (int) ((Number)numbers.get(i)).getValue();
xfIndices[i] = ( (CellValue) numbers.get(i)).getXFIndex();
}
}
示例6: createExcelSheet
import jxl.write.Number; //导入依赖的package包/类
public void createExcelSheet(WritableSheet excelSheet) {
int row, col;
// Create cells
for (row=0; row<nrows; row++)
for (col=0; col<ncolumns[row]; col++) {
if (sheet[row][col]==null)
continue;
try {
if (sheet[row][col].getMerge_to_col()>=0 && sheet[row][col].getMerge_to_row()>=0)
excelSheet.mergeCells(col, row, sheet[row][col].getMerge_to_col(), sheet[row][col].getMerge_to_row());
switch (sheet[row][col].getType()) {
case LABEL:
excelSheet.addCell(new Label(col,row,sheet[row][col].getString(),getExcelFormat(row, col)));
break;
case FLOAT:
case INTEGER:
excelSheet.addCell(new Number(col,row,sheet[row][col].getNumber(),getExcelFormat(row, col)));
break;
case IMAGE:
File f = new File(sheet[row][col].getString());
WritableImage imgobj=new WritableImage(col, row, sheet[row][col].getWidth(), sheet[row][col].getHeight(), f);
excelSheet.addImage(imgobj);
break;
case VOID:
break;
case FORMULA:
excelSheet.addCell( new Formula(col, row, sheet[row][col].getString(),getExcelFormat(row, col)) );
break;
default:
break;
}
} catch (WriteException we) {};
}
// Resize columns
for (col=0; colSize!=null && col<colSize.length; col++)
if (colSize[col]>0)
excelSheet.setColumnView(col, colSize[col]);
}
示例7: addData
import jxl.write.Number; //导入依赖的package包/类
public void addData(int date, double price, double shares) {
list_data.add(new Number(0, nrows, date));
list_data.add(new Number(1, nrows, price));
list_data.add(new Number(2, nrows, shares));
nrows++;
}
示例8: addData
import jxl.write.Number; //导入依赖的package包/类
public void addData(int date, double bid, double ask) {
if (nrows == 1) {
if (bid == 0) {
list_data.add(new Number(0, 1, date));
list_data.add(new Number(1, 1, ask));
list_data.add(new Number(2, 1, ask));
last_bid = ask;
last_ask = ask;
} else {
list_data.add(new Number(0, 1, date));
list_data.add(new Number(1, 1, bid));
list_data.add(new Number(2, 1, bid));
last_bid = bid;
last_ask = bid;
}
} else {
if (bid == 0) {
list_data.add(new Number(0, nrows, date));
list_data.add(new Number(1, nrows, last_bid));
list_data.add(new Number(2, nrows, ask));
last_ask = ask;
} else {
list_data.add(new Number(0, nrows, date));
list_data.add(new Number(1, nrows, bid));
list_data.add(new Number(2, nrows, last_ask));
last_bid = bid;
}
}
nrows++;
}
开发者ID:NicolasGriere,项目名称:High-Frequency-Data-Order-Book-Analyser,代码行数:32,代码来源:ExportChartSpread.java
示例9: addData
import jxl.write.Number; //导入依赖的package包/类
public void addData(int date, double bid, double ask) {
String tmp;
WritableCell cell;
if (nrows == 1) {
if (bid == 0) {
list_data.add(new Number(0, 1, date));
list_data.add(new Number(1, 1, ask));
list_data.add(new Number(2, 1, ask));
last_bid = ask;
last_ask = ask;
} else {
list_data.add(new Number(0, 1, date));
list_data.add(new Number(1, 1, bid));
list_data.add(new Number(2, 1, bid));
last_bid = bid;
last_ask = bid;
}
} else {
if (bid == 0) {
list_data.add(new Number(0, nrows, date));
list_data.add(new Number(1, nrows, last_bid));
list_data.add(new Number(2, nrows, ask));
last_ask = ask;
} else {
list_data.add(new Number(0, nrows, date));
list_data.add(new Number(1, nrows, bid));
list_data.add(new Number(2, nrows, last_ask));
last_bid = bid;
}
}
nrows++;
}
示例10: importXls
import jxl.write.Number; //导入依赖的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();
}
示例11: fillSheet
import jxl.write.Number; //导入依赖的package包/类
private static void fillSheet(WritableSheet sheet, SortedMap<java.lang.Number, java.lang.Number> data)
throws WriteException, RowsExceededException {
int row = 0;
for (java.lang.Number x : data.keySet()) {
// first column
addNumber(sheet, 0, row, x);
// second column
addNumber(sheet, 1, row++, data.get(x));
}
}
示例12: insertDurationCell
import jxl.write.Number; //导入依赖的package包/类
private void insertDurationCell(long durationInSeconds, int row, int column, CellFormat cellFormat) {
double durationInDays = (double) durationInSeconds / (24 * 60 * 60);
if (cellFormat == null) cellFormat = durationInSeconds >= 3600 ? mLongDurationFormat : mShortDurationFormat;
Number number = new Number(column, row, durationInDays, cellFormat);
try {
mSheet.addCell(number);
} catch (JXLException e) {
Log.e(TAG, "writeHeader Could not insert cell " + durationInSeconds + " at row=" + row + ", col=" + column, e);
}
}
示例13: toXlsInternal
import jxl.write.Number; //导入依赖的package包/类
private static void toXlsInternal( Grid grid, WritableWorkbook workbook, String sheetName, int sheetNo )
throws Exception
{
if ( grid == null )
{
return;
}
int cols = grid.getVisibleHeaders().size();
if ( cols > JXL_MAX_COLS )
{
log.warn( "Grid will be truncated, no of columns is greater than JXL max limit: " + cols + "/" + JXL_MAX_COLS );
}
WritableSheet sheet = workbook.createSheet( sheetName, sheetNo );
int rowNumber = 0;
int columnIndex = 0;
if ( StringUtils.isNotEmpty( grid.getTitle() ) )
{
sheet.addCell( new Label( 0, rowNumber++, grid.getTitle(), XLS_FORMAT_TTTLE ) );
rowNumber++;
}
if ( StringUtils.isNotEmpty( grid.getSubtitle() ) )
{
sheet.addCell( new Label( 0, rowNumber++, grid.getSubtitle(), XLS_FORMAT_TTTLE ) );
rowNumber++;
}
List<GridHeader> headers = ListUtils.subList( grid.getVisibleHeaders(), 0, JXL_MAX_COLS );
for ( GridHeader header : headers )
{
sheet.addCell( new Label( columnIndex++, rowNumber, header.getName(), XLS_FORMAT_LABEL ) );
}
rowNumber++;
for ( List<Object> row : grid.getVisibleRows() )
{
columnIndex = 0;
List<Object> colums = ListUtils.subList( row, 0, JXL_MAX_COLS );
for ( Object column : colums )
{
if ( column != null && MathUtils.isNumeric( String.valueOf( column ) ) )
{
sheet.addCell( new Number( columnIndex++, rowNumber, Double.valueOf( String.valueOf( column ) ), XLS_FORMAT_TEXT ) );
}
else
{
String content = column != null ? String.valueOf( column ) : EMPTY;
sheet.addCell( new Label( columnIndex++, rowNumber, content, XLS_FORMAT_TEXT ) );
}
}
rowNumber++;
}
}
示例14: toXlsInternal
import jxl.write.Number; //导入依赖的package包/类
private static void toXlsInternal( Grid grid, WritableWorkbook workbook, String sheetName, int sheetNo )
throws Exception
{
if ( grid == null )
{
return;
}
int cols = grid.getVisibleHeaders().size();
if ( cols > JXL_MAX_COLS )
{
log.warn( "Grid will be truncated, no of columns is greater than JXL max limit: " + cols + "/" + JXL_MAX_COLS );
}
WritableSheet sheet = workbook.createSheet( sheetName, sheetNo );
int rowNumber = 1;
int columnIndex = 0;
if ( StringUtils.isNotEmpty( grid.getTitle() ) )
{
sheet.addCell( new Label( 0, rowNumber++, grid.getTitle(), XLS_FORMAT_TTTLE ) );
rowNumber++;
}
if ( StringUtils.isNotEmpty( grid.getSubtitle() ) )
{
sheet.addCell( new Label( 0, rowNumber++, grid.getSubtitle(), XLS_FORMAT_TTTLE ) );
rowNumber++;
}
List<GridHeader> headers = ListUtils.subList( grid.getVisibleHeaders(), 0, JXL_MAX_COLS );
for ( GridHeader header : headers )
{
sheet.addCell( new Label( columnIndex++, rowNumber, header.getColumn(), XLS_FORMAT_LABEL ) );
}
rowNumber++;
for ( List<Object> row : grid.getVisibleRows() )
{
columnIndex = 0;
List<Object> colums = ListUtils.subList( row, 0, JXL_MAX_COLS );
for ( Object column : colums )
{
if ( column != null && MathUtils.isNumeric( String.valueOf( column ) ) )
{
sheet.addCell( new Number( columnIndex++, rowNumber, Double.valueOf( String.valueOf( column ) ), XLS_FORMAT_TEXT ) );
}
else
{
String content = column != null ? String.valueOf( column ) : EMPTY;
sheet.addCell( new Label( columnIndex++, rowNumber, content, XLS_FORMAT_TEXT ) );
}
}
rowNumber++;
}
}
示例15: WriteData
import jxl.write.Number; //导入依赖的package包/类
private void WriteData() throws WriteException {
for (Number e : list_data) {
out.addCell(e);
}
}