Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2019, Continual.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.continual.services.processor.library.msdocs.sources;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.continual.builder.Builder.BuildFailure;
import io.continual.resources.ResourceLoader;
import io.continual.services.processor.config.readers.ConfigLoadContext;
import io.continual.services.processor.engine.library.sources.BasicSource;
import io.continual.services.processor.engine.model.Message;
import io.continual.services.processor.engine.model.MessageAndRouting;
import io.continual.services.processor.engine.model.StreamProcessingContext;
import io.continual.util.data.json.JsonVisitor;
import io.continual.util.data.json.JsonVisitor.ObjectVisitor;
/**
* An excel spreadsheet stream source. This source will report EOF when all records are read.
*/
public class ExcelSource extends BasicSource
{
public ExcelSource ( JSONObject config ) throws BuildFailure
{
this ( null, config );
}
public ExcelSource ( String defPipeline, String resource, boolean firstLineHeader ) throws BuildFailure
{
super ( defPipeline );
try
{
fResource = resource;
fLineNumberToField = null;
fFirstLineHeader = firstLineHeader;
fFieldMap = new HashMap<> ();
}
catch ( JSONException e )
{
throw new BuildFailure ( e );
}
}
public ExcelSource ( final ConfigLoadContext sc, JSONObject config ) throws BuildFailure
{
super ( config );
try
{
fResource = config.optString ( "data", "" );
fLineNumberToField = config.optString ( "lineNumberTo", null );
fFirstLineHeader = config.optBoolean ( "firstLineHeader", false );
fFieldMap = new HashMap<> ();
JsonVisitor.forEachElement ( config.optJSONObject ( "fieldMap" ), new ObjectVisitor