ExcelImportTable
Upload Excel file to Table components
Upload Excel file to Table components:
Select an Excel file, You can choose to set the header row number, table head line number data starting line number. Or not set using the default settings, example: title line number: 1, the header line numbers: 2, data starting line number: 3 Choose to complete the import to the server-side, click "upload to table" after import Table.
Table, empty data table, you can not add header and data, but must have been instantiated not be empty, otherwise it will error. Similarly, table data table head of the table, If so, then click on "upload to the header tables" after matching detection, detection of the same import to the table, the match fails not import.
Has import, support multi-line headers Excel spreadsheet data NUMERIC (Double, Integer), STRING, Date, BOOLEAN, FORMULA, BLANK, ERROR.
- note: * need to use jar: poi - 3.8-20120326. Jar http://www.apache.org/dyn/closer.cgi/poi/release/bin/poi-bin-3.8-20120326.zip
Sample code
import java.util.Date; import com.vaadin.Application; import com.vaadin.terminal.ThemeResource; import com.vaadin.ui.Embedded; import com.vaadin.ui.Form; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.Table; import com.vaadin.ui.Window; public class ExcelimporttableApplication extends Application { private static final long serialVersionUID = 1051406262161575126L; @Override public void init() { Window mainWindow = new Window("Excelimporttable Application"); Label label = new Label("Excel Import Table - v1.1"); mainWindow.addComponent(label); //TODO 1. Use table have Header, as import object Form f_1 = new Form(); f_1.setCaption("1.Use table have Header, as import object"); mainWindow.addComponent(f_1); Panel p_f_1 = new Panel(); GridLayout layout_f_1 = new GridLayout(2, 1); Table table_f_1 = new Table(""); table_f_1.addContainerProperty("Name", String.class, null); table_f_1.addContainerProperty("Language", String.class, null); table_f_1.addContainerProperty("Double", Double.class, null); table_f_1.addContainerProperty("Date", Date.class, null); table_f_1.addContainerProperty("Integer", Integer.class, null); table_f_1.addContainerProperty("Boolean", Boolean.class, null); table_f_1.addItem(new Object[] {"Nicolaus","Copernicus",new Double(1473), new Date(), new Integer(1), new Boolean(true)}, new Integer(1)); table_f_1.addItem(new Object[] {"Tycho", "Brahe", new Double(1546), new Date(), new Integer(2), new Boolean(true)}, new Integer(2)); table_f_1.addItem(new Object[] {"Giordano","Bruno", new Double(1548), new Date(), new Integer(3), new Boolean(false)}, new Integer(3)); table_f_1.addItem(new Object[] {"Galileo", "Galilei", new Double(1564), new Date(), new Integer(4), new Boolean(false)}, new Integer(4)); table_f_1.addItem(new Object[] {"Johannes","Kepler", new Double(1571), new Date(), new Integer(5), new Boolean(true)}, new Integer(5)); table_f_1.addItem(new Object[] {"Isaac", "Newton", new Double(1643), new Date(), new Integer(16), new Boolean(false)}, new Integer(6)); table_f_1.setHeight("500px"); layout_f_1.addComponent(table_f_1); ThemeResource DemoPic_f_1 = new ThemeResource("../images/demo_f_1.png"); layout_f_1.addComponent(new Embedded("", DemoPic_f_1)); p_f_1.addComponent(layout_f_1); ExcelImportTable eit_f_1 = new ExcelImportTable(table_f_1); p_f_1.addComponent(eit_f_1); mainWindow.addComponent(p_f_1); setMainWindow(mainWindow); } }
import java.util.Date; import com.vaadin.Application; import com.vaadin.terminal.ThemeResource; import com.vaadin.ui.Embedded; import com.vaadin.ui.Form; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.Table; import com.vaadin.ui.Window; public class ExcelimporttableApplication extends Application { private static final long serialVersionUID = 1051406262161575126L; @Override public void init() { Window mainWindow = new Window("Excelimporttable Application"); Label label = new Label("Excel Import Table - v1.1"); mainWindow.addComponent(label); //TODO 2. Use empty table as import object Form f_2 = new Form(); f_2.setCaption("2.Use empty table as import object (default:title line number:1, meter line number:2, data starting line:3)."); mainWindow.addComponent(f_2); Panel p_f_2 = new Panel(); GridLayout layout_f_2 = new GridLayout(2, 1); Table table_f_2 = new Table(); table_f_2.setHeight("500px"); layout_f_2.addComponent(table_f_2); ThemeResource DemoPic_f_2 = new ThemeResource("../images/demo_f_2.png"); layout_f_2.addComponent(new Embedded("", DemoPic_f_2)); p_f_2.addComponent(layout_f_2); ExcelImportTable eit_f_2 = new ExcelImportTable(table_f_2); p_f_2.addComponent(eit_f_2); mainWindow.addComponent(p_f_2); setMainWindow(mainWindow); } }
import java.util.Date; import com.vaadin.Application; import com.vaadin.terminal.ThemeResource; import com.vaadin.ui.Embedded; import com.vaadin.ui.Form; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.Table; import com.vaadin.ui.Window; public class ExcelimporttableApplication extends Application { private static final long serialVersionUID = 1051406262161575126L; @Override public void init() { Window mainWindow = new Window("Excelimporttable Application"); Label label = new Label("Excel Import Table - v1.1"); mainWindow.addComponent(label); //TODO 3. Use empty table as import object?And set import Excel file format (title line number:1, meter line number:2, data starting line:3). Form f_3 = new Form(); f_3.setCaption(" 3. Use empty table as import object?And set import Excel file format (title line number:1, meter line number:2, data starting line:4).( header line count : 2 )"); mainWindow.addComponent(f_3); Panel p_f_3 = new Panel(); GridLayout layout_f_3 = new GridLayout(2, 1); Table table_f_3 = new Table(); table_f_3.setHeight("500px"); layout_f_3.addComponent(table_f_3); ThemeResource DemoPic_f_3 = new ThemeResource("../images/demo_f_3.png"); layout_f_3.addComponent(new Embedded("", DemoPic_f_3)); p_f_3.addComponent(layout_f_3); ExcelImportTable eit_f_3 = new ExcelImportTable(table_f_3,1,2,4); p_f_3.addComponent(eit_f_3); mainWindow.addComponent(p_f_3); setMainWindow(mainWindow); } }
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Version -1.1.0 - (2012-11-29):
Added import data type [strong detection] [weak conversion (for Integer and Double) (If the Table contains the header obtain the type of header do match DealHeader class) 1.1 new warning: type conversion exceptional circumstances : Integer-> Double 1.2 new warning: type conversion exceptional circumstances : Any Type-> String
new Excel file import data types: Date
Refinement Excel file import data type NUMERIC: Integer, Double
Multi-line table entry
new header name repeated error detection
Detection error can input 6.1.excel types of data entry (by example) 6.1.1 date: [2012/8/8], [2012/11/12 22:22:22] 6.1.2 double: [18.0000000000001], [19.42747469] 6.1.3 int: [1], [0], [-1], [14], [65536], [999999], [-999999] 6.1.4 string: [Aaa] [Bbb] [Chinese of (The ZH_CN)] 6.1.5 boolean: [FALSE] [TRUE] 6.1.6 FORMULA: [] 6.1.7 BLANK: [] 6.1.8 ERROR: []
Updated complete Application test case code
Version -1.0.0 - (2012-11-14): 1.Import one-line header ex
- Released
- 2012-11-29
- Maturity
- EXPERIMENTAL
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 6.8+
- Browser
- Internet Explorer
- Internet Explorer
- Firefox
- Opera
- Google Chrome
- Internet Explorer
ExcelImportTable - Vaadin Add-on Directory
Upload Excel file to Table componentsDiscussion Forum
ExcelImportTable version 1.0.0
This version of the function:
1. Import single meter excel file data to the matching meter Table
2. Import single meter excel file header data to the blank Table
ExcelImportTable version 1.1.0
Version -1.1.0 - (2012-11-29):
1. Added import data type [strong detection] [weak conversion (for Integer and Double)
(If the Table contains the header obtain the type of header do match DealHeader class)
1.1 new warning: type conversion exceptional circumstances : Integer-> Double
1.2 new warning: type conversion exceptional circumstances : Any Type-> String
2. new Excel file import data types: Date
3. Refinement Excel file import data type NUMERIC: Integer, Double
4. Multi-line table entry
5. new header name repeated error detection
6. Detection error can input
6.1.excel types of data entry (by example)
6.1.1 date: [2012/8/8], [2012/11/12 22:22:22]
6.1.2 double: [18.0000000000001], [19.42747469]
6.1.3 int: [1], [0], [-1], [14], [65536], [999999], [-999999]
6.1.4 string: [Aaa] [Bbb] [Chinese of (The ZH_CN)]
6.1.5 boolean: [FALSE] [TRUE]
6.1.6 FORMULA: []
6.1.7 BLANK: []
6.1.8 ERROR: []
7. Updated complete Application test case code
Version -1.0.0 - (2012-11-14):
1.Import one-line header ex