本文整理汇总了Java中org.odftoolkit.simple.table.Cell类的典型用法代码示例。如果您正苦于以下问题:Java Cell类的具体用法?Java Cell怎么用?Java Cell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cell类属于org.odftoolkit.simple.table包,在下文中一共展示了Cell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBasicCell
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
public static Cell createBasicCell(final Table table, int colIndex, int rowIndex, Object value) {
final Cell cell = table.getCellByPosition(colIndex, rowIndex);
String strValue;
if (value == null) {
strValue = "";
} else if (value instanceof String) {
strValue = (String) value;
} else if (value instanceof Double) {
Double d = (Double) value;
strValue = LogFrameExportData.AGGR_AVG_FORMATTER.format(d.doubleValue());
} else if (value instanceof Long) {
Long l = (Long) value;
strValue = LogFrameExportData.AGGR_SUM_FORMATTER.format(l.longValue());
} else { // date
strValue = ExportConstants.EXPORT_DATE_FORMAT.format((Date) value);
}
cell.setStringValue(strValue);
cell.setCellStyleName(coreStyleName);
return cell;
}
示例2: getCellValue
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
private Object getCellValue(Cell varCell) {
Object cellValue = null;
if ("boolean".equals(varCell.getValueType())) {
// Boolean
cellValue = varCell.getBooleanValue();
} else if ("time".equals(varCell.getValueType())) {
// Date
cellValue = varCell.getTimeValue().getTime();
} else if ("date".equals(varCell.getValueType())) {
// Date
cellValue = varCell.getDateValue().getTime();
} else if ("float".equals(varCell.getValueType())) {
// Double
cellValue = varCell.getDoubleValue();
} else if ("percentage".equals(varCell.getValueType())) {
// Double
cellValue = varCell.getPercentageValue();
} else if ("currency".equals(varCell.getValueType())) {
// String
cellValue = varCell.getCurrencyCode();
} else {
// String
cellValue = varCell.getStringValue();
}
return cellValue;
}
示例3: addBlock
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
private void addBlock(AsciiElement element) {
final Table table = odtDocument.addTable(1, 1);
Cell cell = table.getCellByPosition(0, 0);
if (element.getName().equals("sidebar"))
cell.setCellBackgroundColor(new Color("#f8f8f7"));
HorizontalAlignmentType type;
Border border = new Border(new Color("#e0e0dc"), 1.0, SupportedLinearMeasure.PT);
if (element.getName().equals("open")) {
type = HorizontalAlignmentType.JUSTIFY;
border.setColor(Color.WHITE);
cell.setBorders(CellBordersType.NONE, border);
} else {
type = HorizontalAlignmentType.CENTER;
cell.setBorders(CellBordersType.ALL_FOUR, border);
}
this.setTitle(element, type, 14, new Color("#7a2518"), cell);
this.buildODTDocument(element.getChildren(), cell);
}
示例4: addAdmonition
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
private void addAdmonition(AsciiElement element) {
this.setTitle(element, FontStyle.ITALIC, HorizontalAlignmentType.LEFT, 12, new Color("#7a2518"), odtDocument);
Table table = odtDocument.addTable(1, 2);
Cell rowOColumn0 = table.getCellByPosition(0, 0);
String caption = getSpecificProperty(element.getjObj(), "caption", String.class);
rowOColumn0.setDisplayText(caption.toUpperCase());
rowOColumn0.setHorizontalAlignment(HorizontalAlignmentType.CENTER);
rowOColumn0.setVerticalAlignment(VerticalAlignmentType.MIDDLE);
Cell rowOColumn1 = table.getCellByPosition(1, 0);
if (element.getNOfBlocks() == 0)
rowOColumn1.setStringValue(element.getContent());
else {
this.buildODTDocument(element.getChildren(), rowOColumn1);
}
Column column = table.getColumnByIndex(0);
column.setUseOptimalWidth(true);
column.setWidth(32.0);
}
示例5: addDList
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
private void addDList(AsciiElement element, Component component) {
final ParagraphContainer paragraphContainer;
final ListContainer listContainer;
if (component instanceof Cell) {
Cell cell = (Cell) component;
paragraphContainer = cell;
listContainer = cell;
} else {
paragraphContainer = odtDocument;
listContainer = odtDocument;
}
int dListBlockLength = element.getItemsLength();
if (dListBlockLength > 0) {
for (int index = 0; index < dListBlockLength; index++) {
// traverse each item combining (dd + dt)
JSObject items = element.getItemByIndex(index);
this.addDListItems(items, paragraphContainer, listContainer);
}
}
}
示例6: setSpanAttributeOfCell
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
private Cell setSpanAttributeOfCell(Table table, Map<String, String> attrs, Cell tableCell, OdfElement container) {
int colSpan = Integer.valueOf(attrs.get("colspan"));
int rowspan = Integer.valueOf(attrs.get("rowspan"));
int row = tableCell.getRowIndex();
int column = tableCell.getColumnIndex();
int tableColumn = table.getColumnCount();
int tableRow = table.getRowCount();
boolean hasOfficeValueType = container.hasAttribute("office:value-type");
if (!hasOfficeValueType) {
if (colSpan != 1 || rowspan != 1) {
colSpan = this.getNewSpanValue(colSpan, column, tableColumn);
rowspan = this.getNewSpanValue(rowspan, row, tableRow);
// spanned attribute in action
CellRange cellRange = table.getCellRangeByPosition(column, row, colSpan, rowspan);
cellRange.merge();
}
} else {
int nextColumn = column + 1;
if (nextColumn != tableColumn)
tableCell = this.getCell(table, row, nextColumn, attrs);
}
return tableCell;
}
示例7: setSpecificFontStyle
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
private void setSpecificFontStyle(String selection, Cell tableCell, Map<String, String> attrs) {
Font font = createFont(12, Color.BLACK);
if (selection.equals("head")) {
font.setFontStyle(FontStyle.BOLDITALIC);
} else if (selection.equals("foot")) {
font.setFontStyle(FontStyle.ITALIC);
} else {
if (attrs.containsKey("style")) {
String style = attrs.get("style");
if (style.equals("strong"))
font.setFontStyle(FontStyle.BOLD);
else if (style.equals("emphasis"))
font.setFontStyle(FontStyle.ITALIC);
else if (style.equals("header"))
font.setFontStyle(FontStyle.BOLDITALIC);
}
}
tableCell.setFont(font);
}
示例8: getCategoryOrder
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
private static List<String> getCategoryOrder(Table table, TableCoordinate headers, ContentDirection fdir) {
List<String> categoryOrder = new ArrayList<String>();
CellRange categoryRange = null;
if (fdir == ContentDirection.VERTICAL) {
categoryRange =
table.getCellRangeByPosition(headers.getColumn(), headers.getRow(), table.getColumnCount() - 1,
headers.getRow());
} else {
categoryRange =
table.getCellRangeByPosition(headers.getColumn(), headers.getRow(), headers.getColumn(),
table.getRowCount() - 1);
}
for (int i = 0; i < categoryRange.getColumnNumber(); i++) {
for (int j = 0; j < categoryRange.getRowNumber(); j++) {
Cell cell = categoryRange.getCellByPosition(i, j);
Paragraph categoryParagraph = cell.getParagraphByIndex(0, false);
String category = null;
if (categoryParagraph == null || (category = categoryParagraph.getTextContent().trim()).isEmpty()) {
logger.warn("Data category missing at (" + i + "," + j + ") in table '" + table.getTableName() + "'.");
categoryOrder.add(null);
} else {
cell.removeParagraph(categoryParagraph);
categoryOrder.add(category);
};
}
}
return categoryOrder;
}
示例9: putHeader
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
public static Cell putHeader(final Row row, int cellIndex, String header) {
Cell cell = row.getCellByIndex(cellIndex);
cell.setStringValue(header);
cell.setBorders(CellBordersType.ALL_FOUR, getBlackBorder());
cell.setCellBackgroundColor(ExportConstants.CALC_COL_GRAY10);
cell.setFont(getBoldFont(10));
cell.setVerticalAlignment(ExportConstants.ALIGN_VER_MIDDLE);
cell.setHorizontalAlignment(ExportConstants.ALIGH_HOR_CENTER);
cell.setTextWrapped(true);
return cell;
}
示例10: putGlobalExportHeader
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
public static Cell putGlobalExportHeader(final Row row, int cellIndex, String header) {
Cell cell = row.getCellByIndex(cellIndex);
cell.setStringValue(header);
cell.setCellStyleName(coreStyleName);
cell.setCellBackgroundColor(ExportConstants.CALC_COL_GRAY5);
cell.setFont(getFont(10, false, true));
return cell;
}
示例11: putMainTitle
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
public static void putMainTitle(final Table table, int rowIndex, int maxCols, String title) {
Row row = table.getRowByIndex(rowIndex);
Cell cell = row.getCellByIndex(1);
cell.setStringValue(title);
cell.setTextWrapped(true);
cell.setFont(CalcUtils.getBoldFont(14));
cell.setVerticalAlignment(ExportConstants.ALIGN_VER_MIDDLE);
cell.setHorizontalAlignment(ExportConstants.ALIGH_HOR_CENTER);
CellRange cellRange = table.getCellRangeByPosition(1, rowIndex, maxCols, rowIndex);
cellRange.merge();
row.setHeight(7, false);
}
示例12: getText
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
public static String getText(SpreadsheetDocument spreadsheetDocument) {
try {
StringBuilder stringBuilder = new StringBuilder("");
int sheetCount = spreadsheetDocument.getSheetCount();
for(int i=0; i<sheetCount; i++) {
Table sheet = spreadsheetDocument.getSheetByIndex(i);
int rowCount = sheet.getRowCount();
for(int y=0; y<rowCount; y++) {
Row row = sheet.getRowByIndex(y);
int cellCount = row.getCellCount();
for(int x=0; x<cellCount; x++) {
Cell cell = row.getCellByIndex(x);
String value = cell.getStringValue();
stringBuilder.append(value);
stringBuilder.append("\t");
}
stringBuilder.append("\n");
}
stringBuilder.append("\n\n");
}
return stringBuilder.toString();
}
catch(Exception e) {
e.printStackTrace();
}
return null;
}
示例13: addList
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
private void addList(AsciiElement element, Component component) {
final ListContainer listContainer;
final ParagraphContainer paragraphContainer;
if (component instanceof Cell) {
Cell cell = (Cell) component;
listContainer = cell;
paragraphContainer = cell;
} else {
listContainer = odtDocument;
paragraphContainer = odtDocument;
}
this.setTitle(element, FontStyle.ITALIC, HorizontalAlignmentType.LEFT, 12, new Color("#7a2518"), paragraphContainer);
this.addListItems(element, listContainer);
}
示例14: editCell
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
private void editCell(AsciiElement element, Table table, String selection, int rowTableIndex, int rowElement, int column) {
JSObject documentCell = element.getCell(selection, rowElement, column);
Map<String, String> attrs = this.getCellAttributes(documentCell);
String cellText = this.getSpecificProperty(documentCell, "text", String.class);
Cell tableCell = this.getCell(table, rowTableIndex, column, attrs);
this.setAlignmentTypes(attrs, tableCell);
this.setSpecificFontStyle(selection, tableCell, attrs);
this.setBorderRight(tableCell);
tableCell.setStringValue($(cellText));
}
示例15: getCell
import org.odftoolkit.simple.table.Cell; //导入依赖的package包/类
private Cell getCell(Table table, int rowTableIndex, int column, Map<String, String> attrs) {
Cell tableCell = table.getCellByPosition(column, rowTableIndex);
OdfElement container = tableCell.getFrameContainerElement();
String localName = container.getOdfName().getLocalName();
if (localName.equals("table-cell")) {
tableCell = this.setSpanAttributeOfCell(table, attrs, tableCell, container);
} else if (localName.equals("covered-table-cell")) {
tableCell = this.getCell(table, rowTableIndex, column + 1, attrs);
}
return tableCell;
}