Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.vaadin.demo</groupId>
<artifactId>vaadin-spreadsheet-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Spreadsheet Add-on Demo</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
Expand Down Expand Up @@ -63,24 +63,24 @@ private void initSpreadsheet() {
fontBoldExample.setBold(true);
CellStyle fontBoldExampleStyle = spreadsheet.getWorkbook()
.createCellStyle();
fontBoldExampleStyle.setFillBackgroundColor(HSSFColor.YELLOW.index);
fontBoldExampleStyle.setFillBackgroundColor(HSSFColorPredefined.YELLOW.getIndex());
fontBoldExampleStyle.setFont(fontBoldExample);
Cell fontExampleCell = spreadsheet.createCell(0, 0,
"Click the 'B' button in the top left corner to toggle bold font on and off.");
fontExampleCell.setCellStyle(fontBoldExampleStyle);

CellStyle backgroundColorStyle = spreadsheet.getWorkbook()
.createCellStyle();
backgroundColorStyle.setFillBackgroundColor(HSSFColor.YELLOW.index);
backgroundColorStyle.setFillBackgroundColor(HSSFColorPredefined.YELLOW.getIndex());
Cell backgroundExampleCell = spreadsheet.createCell(2, 0,
"Click the 'Background Color' button to select and change the background color of a cell.");
backgroundExampleCell.setCellStyle(backgroundColorStyle);

Font fontColorExample = spreadsheet.getWorkbook().createFont();
fontColorExample.setColor(HSSFColor.LIGHT_BLUE.index);
fontColorExample.setColor(HSSFColorPredefined.LIGHT_BLUE.getIndex());
CellStyle fontColorExampleStyle = spreadsheet.getWorkbook()
.createCellStyle();
fontColorExampleStyle.setFillBackgroundColor(HSSFColor.YELLOW.index);
fontColorExampleStyle.setFillBackgroundColor(HSSFColorPredefined.YELLOW.getIndex());
fontColorExampleStyle.setFont(fontColorExample);
Cell fontColorExampleCell = spreadsheet.createCell(4, 0,
"Click the 'Font Color' button to select and change the font color of a cell.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.vaadin.addon.spreadsheet.demo.examples;

import static org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA;
import static org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC;
import static org.reflections.util.Utils.isEmpty;

import java.util.ArrayList;
import java.util.Collection;

import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType;

import com.vaadin.addon.charts.Chart;
import com.vaadin.addon.charts.model.ChartType;
Expand Down Expand Up @@ -106,7 +105,7 @@ public void onCellValueChange(CellValueChangeEvent event) {
});
CellStyle backgroundColorStyle = spreadsheet.getWorkbook()
.createCellStyle();
backgroundColorStyle.setFillBackgroundColor(HSSFColor.YELLOW.index);
backgroundColorStyle.setFillBackgroundColor(HSSFColorPredefined.YELLOW.getIndex());
Cell cell = spreadsheet.createCell(0, 0,
"Edit this spreadsheet to alter chart title and data");
cell.setCellStyle(backgroundColorStyle);
Expand Down Expand Up @@ -166,17 +165,17 @@ private void updateChartData(Chart chart) {
private String getStringValue(int rowIndex, int columnIndex) {
Cell cell = spreadsheet.getCell(rowIndex, columnIndex);
if (cell != null) {
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellType(CellType.STRING);
return cell.getStringCellValue();
}
return null;
}

private Double getNumericValue(int rowIndex, int columnIndex) {
Cell cell = spreadsheet.getCell(rowIndex, columnIndex);
if (cell != null && (cell.getCellType() == CELL_TYPE_NUMERIC
|| (cell.getCellType() == CELL_TYPE_FORMULA && cell
.getCachedFormulaResultType() == CELL_TYPE_NUMERIC))) {
if (cell != null && (cell.getCellType() == CellType.NUMERIC
|| (cell.getCellType() == CellType.FORMULA && cell
.getCachedFormulaResultType() == CellType.NUMERIC))) {
return cell.getNumericCellValue();
}
return 0d;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.io.OutputStream;

import org.apache.commons.io.IOUtils;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;

Expand Down Expand Up @@ -83,7 +83,7 @@ private void initSpreadsheetPanel() {
Spreadsheet spreadsheet = new Spreadsheet();
CellStyle backgroundColorStyle = spreadsheet.getWorkbook()
.createCellStyle();
backgroundColorStyle.setFillBackgroundColor(HSSFColor.YELLOW.index);
backgroundColorStyle.setFillBackgroundColor(HSSFColorPredefined.YELLOW.getIndex());
Cell cell = spreadsheet.createCell(0, 0,
"Click the upload button to choose and upload an excel file.");
cell.setCellStyle(backgroundColorStyle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.ExcelStyleDateFormatter;
import org.apache.poi.ss.usermodel.Row;
Expand Down Expand Up @@ -79,7 +80,7 @@ public TestComponentFactory() {
testWorkbook = new XSSFWorkbook();
final Sheet sheet = getTestWorkbook().createSheet("Custom Components");
Row lastRow = sheet.createRow(100);
lastRow.createCell(100, Cell.CELL_TYPE_BOOLEAN).setCellValue(true);
lastRow.createCell(100, CellType.BOOLEAN).setCellValue(true);
sheet.setColumnWidth(0, 7800);
sheet.setColumnWidth(1, 3800);
sheet.setColumnWidth(2, 6100);
Expand All @@ -95,9 +96,9 @@ public TestComponentFactory() {
Object value = data[i][j];
if (i == 0 || j == 0 || j == 4 || j == 5) {
// string cells
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellType(CellType.STRING);
} else if (j == 2 || j == 3) {
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
cell.setCellType(CellType.NUMERIC);
}
final DataFormat format = getTestWorkbook().createDataFormat();
if (value != null) {
Expand Down Expand Up @@ -259,7 +260,7 @@ public void onCustomEditorDisplayed(Cell cell, int rowIndex,
}

if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
if (cell.getCellType() == CellType.BOOLEAN) {
((CheckBox) customEditor).setValue(cell.getBooleanCellValue());
} else if (customEditor instanceof DateField) {
final String s = cell.getCellStyle().getDataFormatString();
Expand Down Expand Up @@ -431,4 +432,4 @@ public Spreadsheet getSpreadsheet() {
return componentsExample.getSpreadsheet();
}

}
}