Why did I want to use data file as data source and no data display?
-
Now .I try to use data file ( excel file) as a data source .
But when I choosen the data source and build data point in mango .
and no data to display?whether where did I setting up is error?
Attachment: download link
-
No answer.
:( -
From the help text:
Overview
The Data File Data Source is intended to poll a particular directory for files, and either adds the parsed points to itself as Mango data points or uses it to map the file's identifiers to other points within Mango. Currently, the data source is ready to accept XML, CSV, and Excel documents after some custom coding, explained in the related links:
Creating Excel Import Classes
Excel files are parsed using a minor variation of the AbstractSheetEmporter class found in com.serotonin.vo.emport called AbstractSheetDataSource, which imposes no further constraints on the subclass, as far as methods that must be implemented. Instead the implementer should call parsedPoints.add(ImportPoint pnt) from within the importRow(Row rowData) method. Following is a sample implementation:
import java.util.List; import org.apache.commons.lang3.ArrayUtils; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import com.serotonin.m2m2.vo.emport.SpreadsheetException; import com.infiniteautomation.datafilesource.dataimage.AlphanumericImportPoint; import com.infiniteautomation.datafilesource.dataimage.BinaryImportPoint; import com.infiniteautomation.datafilesource.dataimage.NumericImportPoint; /* * @author Phillip Dunlap * General format accepted: cell(0,0) is empty, row(0) contains point names to be identified by the ds's * data points, column(0) is epoch timestamps, and cell(m,n) is the value of point (row(0),cell(m)) at time (row(n),cell(0)) */ public class ColumnBasedSheetImporter extends AbstractSheetDataSource { //Generated in the datasource at polling runtime against the set of data points String[] xidMap; //Also generated, used to set values @Override protected String getSheetName() { return "nameOfSheetInExcel"; } @Override public void setHeaders(String[] headers) { String[] cell0 = {"corner"}; //Cell(0,0) is empty this.headers = ArrayUtils.addAll(cell0, headers); } public void setXids(String[] xidMap) { this.xidMap = xidMap; } @Override public boolean takesPointHeaders() { return true; } @Override protected void importRow(Row rowData) throws SpreadsheetException { if(rowData.getPhysicalNumberOfCells() <= 0) return; long ts = (long) rowData.getCell(0).getNumericCellValue(); for(int k = 1; k < rowData.getPhysicalNumberOfCells(); ++k) { switch(rowData.getCell(k).getCellType()) { case Cell.CELL_TYPE_NUMERIC : parsedPoints.add(new NumericImportPoint(xidMap[k-1], rowData.getCell(k).getNumericCellValue(), ts)); break; case Cell.CELL_TYPE_BOOLEAN : parsedPoints.add(new BinaryImportPoint(xidMap[k-1], rowData.getCell(k).getBooleanCellValue(), ts)); break; case Cell.CELL_TYPE_STRING : parsedPoints.add(new AlphanumericImportPoint(xidMap[k-1], rowData.getCell(k).getStringCellValue(), ts)); break; default : //parsedPoints.add(new AlphanumericImportPoint(xidMap[k-1], rowData.getCell(k).toString(), ts)); break; } } } @Override protected CellType[] getColumnTypes() { // Not Implemented return null; } @Override protected int[] getColumnWidths() { // Not Implemented return null; } @Override protected List<List<Object>> exportRows() { // Not Implemented return null; } }
So you will need to write some code for Mango to import data from a XLS file.