@Override
public void create(OutputStream oStream, Map<String,InputStream> linkedWorkbooks,Map<String,String> linkedWorkbooksPasswords, InputStream template) throws OfficeWriterException {
	this.oStream=oStream;
	// check if we should load a workbook from template
	if(template!=null){
		LOG.info("Loading template: "+this.howc.getTemplate());
		if (this.howc.getLowFootprint()) {
			LOG.warn("Low footprint mode is not supported with templates. Continuing normal mode");
		}
		this.hasTemplate=true;
		HadoopOfficeReadConfiguration currentTemplateHOCR = new HadoopOfficeReadConfiguration();
		currentTemplateHOCR.setLocale(this.howc.getLocale());
		currentTemplateHOCR.setSheets(null);
		currentTemplateHOCR.setIgnoreMissingLinkedWorkbooks(this.howc.getIgnoreMissingLinkedWorkbooks());
		currentTemplateHOCR.setMetaDataFilter(null);
		currentTemplateHOCR.setPassword(this.howc.getTemplatePassword());
		MSExcelParser currentTemplateParser = new MSExcelParser(currentTemplateHOCR,null);
		try {
			currentTemplateParser.parse(template);
		} catch (FormatNotUnderstoodException e) {
			LOG.error(e);
			LOG.error("Cannot read template");
			throw new OfficeWriterException(e.toString());
		}
		this.currentWorkbook=currentTemplateParser.getCurrentWorkbook();
	} else {
		// create a new Workbook either in old Excel or "new" Excel format
		if (this.format.equals(MSExcelWriter.FORMAT_OOXML)) {
			this.currentWorkbook=new XSSFWorkbook();
			this.ooxmlDocumentFileSystem = new POIFSFileSystem();					
		} else if (this.format.equals(MSExcelWriter.FORMAT_OLD)) {
			if (this.howc.getLowFootprint()) {
				LOG.warn("Low footprint mode writing is not supported for old Excel files (.xls). Continuing normal mode");
			}
			this.currentWorkbook=new HSSFWorkbook();
			((HSSFWorkbook)this.currentWorkbook).createInformationProperties();
		} 
	}
	FormulaEvaluator currentFormulaEvaluator=this.currentWorkbook.getCreationHelper().createFormulaEvaluator();
	HashMap<String,FormulaEvaluator> linkedFormulaEvaluators=new HashMap<>();
	linkedFormulaEvaluators.put(this.howc.getFileName(),currentFormulaEvaluator);
	this.mappedDrawings=new HashMap<>();
	// add current workbook to list of linked workbooks
	this.listOfWorkbooks=new ArrayList<>();
	// parse linked workbooks
	try {
		for (Map.Entry<String,InputStream> entry: linkedWorkbooks.entrySet()) {
			// parse linked workbook
			HadoopOfficeReadConfiguration currentLinkedWBHOCR = new HadoopOfficeReadConfiguration();
			currentLinkedWBHOCR.setLocale(this.howc.getLocale());
			currentLinkedWBHOCR.setSheets(null);
			currentLinkedWBHOCR.setIgnoreMissingLinkedWorkbooks(this.howc.getIgnoreMissingLinkedWorkbooks());
			currentLinkedWBHOCR.setFileName(entry.getKey());
			currentLinkedWBHOCR.setPassword(linkedWorkbooksPasswords.get(entry.getKey()));
			currentLinkedWBHOCR.setMetaDataFilter(null);
			MSExcelParser currentLinkedWorkbookParser = new MSExcelParser(currentLinkedWBHOCR,null);
			try {
				currentLinkedWorkbookParser.parse(entry.getValue());
			} catch (FormatNotUnderstoodException e) {
				LOG.error(e);
				throw new OfficeWriterException(e.toString());
			}
			this.listOfWorkbooks.add(currentLinkedWorkbookParser.getCurrentWorkbook());
			linkedFormulaEvaluators.put(entry.getKey(),currentLinkedWorkbookParser.getCurrentFormulaEvaluator());
			this.currentWorkbook.linkExternalWorkbook(entry.getKey(),currentLinkedWorkbookParser.getCurrentWorkbook());
		}
					
	} finally {	// close linked workbook inputstreams
		for (InputStream currentIS: linkedWorkbooks.values()) {
			try {
				currentIS.close();
			} catch (IOException e) {
				LOG.error(e);
			}
		}
	}
	LOG.debug("Size of linked formula evaluators map: "+linkedFormulaEvaluators.size());
	currentFormulaEvaluator.setupReferencedWorkbooks(linkedFormulaEvaluators);
	if (this.howc.getSigKey()!=null) { // use temporary files for signatures
		try {
			this.signUtil= new MSExcelOOXMLSignUtil(this.oStream);
		} catch (IOException e) {
			LOG.error("Cannot create sign utilities "+e);
			throw new OfficeWriterException(e.toString());
		}
	}
}
@ Override public void create ( OutputStream oStream , Map < String , InputStream > linkedWorkbooks , Map < String , String > linkedWorkbooksPasswords , InputStream template ) throws OfficeWriterException { this . oStream = oStream ; if ( template != null ) { LOG . info ( "Loading template: " + this . howc . getTemplate ( ) ) ; if ( this . howc . getLowFootprint ( ) ) { LOG . warn ( "Low footprint mode is not supported with templates. Continuing normal mode" ) ; } this . hasTemplate = true ; HadoopOfficeReadConfiguration currentTemplateHOCR = new HadoopOfficeReadConfiguration ( ) ; currentTemplateHOCR . setLocale ( this . howc . getLocale ( ) ) ; currentTemplateHOCR . setSheets ( null ) ; currentTemplateHOCR . setIgnoreMissingLinkedWorkbooks ( this . howc . getIgnoreMissingLinkedWorkbooks ( ) ) ; currentTemplateHOCR . setMetaDataFilter ( null ) ; currentTemplateHOCR . setPassword ( this . howc . getTemplatePassword ( ) ) ; MSExcelParser currentTemplateParser = new MSExcelParser ( currentTemplateHOCR , null ) ; try { currentTemplateParser . parse ( template ) ; } catch ( FormatNotUnderstoodException e ) { LOG . error ( e ) ; LOG . error ( "Cannot read template" ) ; throw new OfficeWriterException ( e . toString ( ) ) ; } this . currentWorkbook = currentTemplateParser . getCurrentWorkbook ( ) ; } else { if ( this . format . equals ( MSExcelWriter . FORMAT_OOXML ) ) { this . currentWorkbook = new XSSFWorkbook ( ) ; this . ooxmlDocumentFileSystem = new POIFSFileSystem ( ) ; } else if ( this . format . equals ( MSExcelWriter . FORMAT_OLD ) ) { if ( this . howc . getLowFootprint ( ) ) { LOG . warn ( "Low footprint mode writing is not supported for old Excel files (.xls). Continuing normal mode" ) ; } this . currentWorkbook = new HSSFWorkbook ( ) ; ( ( HSSFWorkbook ) this . currentWorkbook ) . createInformationProperties ( ) ; } } FormulaEvaluator currentFormulaEvaluator = this . currentWorkbook . getCreationHelper ( ) . createFormulaEvaluator ( ) ; HashMap < String , FormulaEvaluator > linkedFormulaEvaluators = new HashMap < > ( ) ; linkedFormulaEvaluators . put ( this . howc . getFileName ( ) , currentFormulaEvaluator ) ; this . mappedDrawings = new HashMap < > ( ) ; this . listOfWorkbooks = new ArrayList < > ( ) ; try { for ( Map . Entry < String , InputStream > entry : linkedWorkbooks . entrySet ( ) ) { HadoopOfficeReadConfiguration currentLinkedWBHOCR = new HadoopOfficeReadConfiguration ( ) ; currentLinkedWBHOCR . setLocale ( this . howc . getLocale ( ) ) ; currentLinkedWBHOCR . setSheets ( null ) ; currentLinkedWBHOCR . setIgnoreMissingLinkedWorkbooks ( this . howc . getIgnoreMissingLinkedWorkbooks ( ) ) ; currentLinkedWBHOCR . setFileName ( entry . getKey ( ) ) ; currentLinkedWBHOCR . setPassword ( linkedWorkbooksPasswords . get ( entry . getKey ( ) ) ) ; currentLinkedWBHOCR . setMetaDataFilter ( null ) ; MSExcelParser currentLinkedWorkbookParser = new MSExcelParser ( currentLinkedWBHOCR , null ) ; try { currentLinkedWorkbookParser . parse ( entry . getValue ( ) ) ; } catch ( FormatNotUnderstoodException e ) { LOG . error ( e ) ; throw new OfficeWriterException ( e . toString ( ) ) ; } this . listOfWorkbooks . add ( currentLinkedWorkbookParser . getCurrentWorkbook ( ) ) ; linkedFormulaEvaluators . put ( entry . getKey ( ) , currentLinkedWorkbookParser . getCurrentFormulaEvaluator ( ) ) ; this . currentWorkbook . linkExternalWorkbook ( entry . getKey ( ) , currentLinkedWorkbookParser . getCurrentWorkbook ( ) ) ; } } finally { for ( InputStream currentIS : linkedWorkbooks . values ( ) ) { try { currentIS . close ( ) ; } catch ( IOException e ) { LOG . error ( e ) ; } } } LOG . debug ( "Size of linked formula evaluators map: " + linkedFormulaEvaluators . size ( ) ) ; currentFormulaEvaluator . setupReferencedWorkbooks ( linkedFormulaEvaluators ) ; if ( this . howc . getSigKey ( ) != null ) { try { this . signUtil = new MSExcelOOXMLSignUtil ( this . oStream ) ; } catch ( IOException e ) { LOG . error ( "Cannot create sign utilities " + e ) ; throw new OfficeWriterException ( e . toString ( ) ) ; } } }
Creates a new Excel workbook for the output stream. Note: You need to save it AFTER adding the cells via addSpreadSheetCell using the method finalizeWrite

@param oStream OutputStream where the Workbook should be written when calling finalizeWrite
@param linkedWorkbooks linked workbooks that are already existing and linked to this spreadsheet
@param linkedWorkbooksPasswords a map of passwords and linkedworkbooks. The key is the filename without path of the linkedworkbook and the value is the password
@param template a template that should be use as base for the document to write, null if there is no template
@throws org.zuinnote.hadoop.office.format.common.writer.OfficeWriterException in  case of errors writing to the outputstream