// CodeGear C++Builder
// Copyright (c) 1995, 2020 by Embarcadero Technologies, Inc.
// All rights reserved

// (DO NOT EDIT: machine generated header) 'QImport3Xlsx.pas' rev: 34.00 (Windows)

#ifndef Qimport3xlsxHPP
#define Qimport3xlsxHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member 
#pragma pack(push,8)
#include <System.hpp>
#include <SysInit.hpp>
#include <System.Classes.hpp>
#include <System.SysUtils.hpp>
#include <System.IniFiles.hpp>
#include <System.StrUtils.hpp>
#include <System.Variants.hpp>
#include <QImport3StrTypes.hpp>
#include <QImport3.hpp>
#include <QImport3Common.hpp>
#include <QImport3XMLBased.hpp>
#include <QImport3XlsxMapParser.hpp>
#include <QImport3XMLSax.hpp>
#include <QImport3BaseDocumentFile.hpp>
#include <System.WideStrings.hpp>

//-- user supplied -----------------------------------------------------------

namespace Qimport3xlsx
{
//-- forward type declarations -----------------------------------------------
class DELPHICLASS TXlsxStyle;
class DELPHICLASS TXlsxStyleList;
class DELPHICLASS TXlsxMerge;
class DELPHICLASS TXlsxMergeList;
class DELPHICLASS TXlsxCell;
class DELPHICLASS TXlsxCellList;
class DELPHICLASS TXlsxWorkSheet;
class DELPHICLASS TXlsxWorkSheetList;
struct TXMLCType;
class DELPHICLASS TXlsxWorkbook;
class DELPHICLASS TXlsxDirectReadWorkbook;
class DELPHICLASS TXlsxFile;
class DELPHICLASS TXlsxDirectReadFile;
class DELPHICLASS TXlsxWorksheetReader;
class DELPHICLASS TQImport3Xlsx;
//-- type declarations -------------------------------------------------------
class PASCALIMPLEMENTATION TXlsxStyle : public System::Classes::TCollectionItem
{
	typedef System::Classes::TCollectionItem inherited;
	
private:
	int FNumFmtId;
	System::UnicodeString FFormatString;
	
public:
	__property int NumFmtId = {read=FNumFmtId, write=FNumFmtId, nodefault};
	__property System::UnicodeString FormatString = {read=FFormatString, write=FFormatString};
public:
	/* TCollectionItem.Create */ inline __fastcall virtual TXlsxStyle(System::Classes::TCollection* Collection) : System::Classes::TCollectionItem(Collection) { }
	/* TCollectionItem.Destroy */ inline __fastcall virtual ~TXlsxStyle() { }
	
};


class PASCALIMPLEMENTATION TXlsxStyleList : public System::Classes::TCollection
{
	typedef System::Classes::TCollection inherited;
	
public:
	TXlsxStyle* operator[](int Index) { return this->Items[Index]; }
	
private:
	HIDESBASE TXlsxStyle* __fastcall GetItem(int Index);
	HIDESBASE void __fastcall SetItem(int Index, TXlsxStyle* const Value);
	
public:
	HIDESBASE TXlsxStyle* __fastcall Add();
	bool __fastcall FindByNumFmtId(int NumFmtId, TXlsxStyle* &TheXlsxStyle);
	void __fastcall SetFormatStringByNumFmtId(const int NumFmtId, const System::UnicodeString FormatString);
	__property TXlsxStyle* Items[int Index] = {read=GetItem, write=SetItem/*, default*/};
public:
	/* TCollection.Create */ inline __fastcall TXlsxStyleList(System::Classes::TCollectionItemClass ItemClass) : System::Classes::TCollection(ItemClass) { }
	/* TCollection.Destroy */ inline __fastcall virtual ~TXlsxStyleList() { }
	
};


class PASCALIMPLEMENTATION TXlsxMerge : public System::Classes::TCollectionItem
{
	typedef System::Classes::TCollectionItem inherited;
	
private:
	System::WideString FRange;
	System::WideString FValue;
	int FBeginRow;
	int FBeginCol;
	int FEndRow;
	int FEndCol;
	System::WideString FFirstCellName;
	void __fastcall SetRange(const System::WideString Value);
	
public:
	__property System::WideString Range = {read=FRange, write=SetRange};
	__property System::WideString Value = {read=FValue, write=FValue};
	__property System::WideString FirstCellName = {read=FFirstCellName};
	__property int BeginRow = {read=FBeginRow, nodefault};
	__property int BeginCol = {read=FBeginCol, nodefault};
	__property int EndRow = {read=FEndRow, nodefault};
	__property int EndCol = {read=FEndCol, nodefault};
public:
	/* TCollectionItem.Create */ inline __fastcall virtual TXlsxMerge(System::Classes::TCollection* Collection) : System::Classes::TCollectionItem(Collection) { }
	/* TCollectionItem.Destroy */ inline __fastcall virtual ~TXlsxMerge() { }
	
};


class PASCALIMPLEMENTATION TXlsxMergeList : public System::Classes::TCollection
{
	typedef System::Classes::TCollection inherited;
	
public:
	TXlsxMerge* operator[](int Index) { return this->Items[Index]; }
	
private:
	HIDESBASE TXlsxMerge* __fastcall GetItem(int Index);
	HIDESBASE void __fastcall SetItem(int Index, TXlsxMerge* const Value);
	
public:
	HIDESBASE TXlsxMerge* __fastcall Add();
	__property TXlsxMerge* Items[int Index] = {read=GetItem, write=SetItem/*, default*/};
public:
	/* TCollection.Create */ inline __fastcall TXlsxMergeList(System::Classes::TCollectionItemClass ItemClass) : System::Classes::TCollection(ItemClass) { }
	/* TCollection.Destroy */ inline __fastcall virtual ~TXlsxMergeList() { }
	
};


class PASCALIMPLEMENTATION TXlsxCell : public Qimport3xmlbased::TCell
{
	typedef Qimport3xmlbased::TCell inherited;
	
private:
	System::UnicodeString FName;
	System::UnicodeString FFormula;
	bool FIsFormulaExist;
	bool FIsMerge;
	void __fastcall SetFormula(const System::UnicodeString Value);
	System::UnicodeString __fastcall GetName();
	void __fastcall SetName(const System::UnicodeString Value);
	
public:
	__fastcall virtual TXlsxCell(System::Classes::TCollection* Collection);
	__property System::UnicodeString Name = {read=GetName, write=SetName};
	__property bool IsMerge = {read=FIsMerge, write=FIsMerge, nodefault};
	__property System::UnicodeString Formula = {read=FFormula, write=SetFormula};
	__property bool IsFormulaExist = {read=FIsFormulaExist, nodefault};
public:
	/* TCell.Destroy */ inline __fastcall virtual ~TXlsxCell() { }
	
};


class PASCALIMPLEMENTATION TXlsxCellList : public Qimport3xmlbased::TCellList
{
	typedef Qimport3xmlbased::TCellList inherited;
	
public:
	TXlsxCell* operator[](int Index) { return this->Items[Index]; }
	
private:
	HIDESBASE TXlsxCell* __fastcall GetItem(int Index);
	HIDESBASE void __fastcall SetItem(int Index, TXlsxCell* const Value);
	
public:
	HIDESBASE TXlsxCell* __fastcall Add();
	__property TXlsxCell* Items[int Index] = {read=GetItem, write=SetItem/*, default*/};
public:
	/* TOwnedCollection.Create */ inline __fastcall TXlsxCellList(System::Classes::TPersistent* AOwner, System::Classes::TCollectionItemClass ItemClass) : Qimport3xmlbased::TCellList(AOwner, ItemClass) { }
	
public:
	/* TCollection.Destroy */ inline __fastcall virtual ~TXlsxCellList() { }
	
};


class PASCALIMPLEMENTATION TXlsxWorkSheet : public Qimport3xmlbased::TXMLSheet
{
	typedef Qimport3xmlbased::TXMLSheet inherited;
	
private:
	int FSheetID;
	TXlsxMergeList* FMergeCells;
	bool FIsHidden;
	System::WideString FFileName;
	HIDESBASE TXlsxCell* __fastcall GetCell(int Col, int Row);
	TXlsxCellList* __fastcall GetCells();
	HIDESBASE void __fastcall SetCell(int Col, int Row, TXlsxCell* const Value);
	void __fastcall SetSheetID(const int Value);
	
protected:
	virtual Qimport3xmlbased::TCellList* __fastcall CreateCells();
	
public:
	__fastcall virtual TXlsxWorkSheet(System::Classes::TCollection* Collection);
	__fastcall virtual ~TXlsxWorkSheet();
	void __fastcall FillMerge(TXlsxCell* Cell);
	__property TXlsxCell* Cell[int Col][int Row] = {read=GetCell, write=SetCell};
	__property int SheetID = {read=FSheetID, write=SetSheetID, nodefault};
	__property TXlsxCellList* Cells = {read=GetCells};
	__property TXlsxMergeList* MergeCells = {read=FMergeCells};
	__property bool IsHidden = {read=FIsHidden, write=FIsHidden, nodefault};
	__property System::WideString FileName = {read=FFileName, write=FFileName};
};


class PASCALIMPLEMENTATION TXlsxWorkSheetList : public Qimport3xmlbased::TXMLSheetList
{
	typedef Qimport3xmlbased::TXMLSheetList inherited;
	
public:
	TXlsxWorkSheet* operator[](int Index) { return this->Items[Index]; }
	
private:
	HIDESBASE TXlsxWorkSheet* __fastcall GetItems(int Index);
	HIDESBASE void __fastcall SetItems(int Index, TXlsxWorkSheet* Value);
	
public:
	HIDESBASE TXlsxWorkSheet* __fastcall Add();
	__property TXlsxWorkSheet* Items[int Index] = {read=GetItems, write=SetItems/*, default*/};
	TXlsxWorkSheet* __fastcall GetFirstSheet();
	TXlsxWorkSheet* __fastcall GetSheetByName(System::WideString Name);
	TXlsxWorkSheet* __fastcall GetSheetByID(int id);
public:
	/* TCollection.Create */ inline __fastcall TXlsxWorkSheetList(System::Classes::TCollectionItemClass ItemClass) : Qimport3xmlbased::TXMLSheetList(ItemClass) { }
	/* TCollection.Destroy */ inline __fastcall virtual ~TXlsxWorkSheetList() { }
	
};


struct DECLSPEC_DRECORD TXMLCType
{
public:
	System::Variant NodeValueT;
	System::Variant NodeValueV;
	System::Variant NodeValueS;
	System::WideString ValueIsT;
};


typedef TXMLCType *PXMLCType;

class PASCALIMPLEMENTATION TXlsxWorkbook : public Qimport3xmlbased::TXMLDocContainer
{
	typedef Qimport3xmlbased::TXMLDocContainer inherited;
	
private:
	TXMLCType *FCurrentValue;
	System::WideString FSharedStringCache;
	TXlsxStyleList* FStylesXfs;
	TXlsxStyleList* FStylesFmt;
	bool FLoadHiddenSheets;
	bool FNeedFillMerge;
	int FImportRecCount;
	void __fastcall CompressCells();
	void __fastcall LoadSharedStrings();
	void __fastcall LoadStyles();
	void __fastcall LoadWorkSheets();
	System::Variant __fastcall FormatValueByStyle(TXlsxStyle* const Style, const System::Variant &Value);
	TXlsxWorkSheetList* __fastcall GetSheets();
	TXlsxWorkSheet* __fastcall GetCurrentSheet();
	TXlsxCell* __fastcall GetCurrentCell();
	void __fastcall OnLoadStyle(Qimport3xmlsax::TQIXMLStreamProcessor* Sender, const System::WideString AName, Qimport3xmlsax::TQIXMLNodeAction Action);
	void __fastcall OnLoadRelationship(Qimport3xmlsax::TQIXMLStreamProcessor* Sender, const System::WideString AName, Qimport3xmlsax::TQIXMLNodeAction Action);
	void __fastcall OnGetSharedString(Qimport3xmlsax::TQIXMLStreamProcessor* Sender, const System::WideString Text, Qimport3xmlsax::TQIXMLTextType TextType);
	void __fastcall OnLoadElement(Qimport3xmlsax::TQIXMLStreamProcessor* Sender, const System::WideString Name, Qimport3xmlsax::TQIXMLNodeAction Action);
	void __fastcall OnLoadCell(Qimport3xmlsax::TQIXMLStreamProcessor* Sender, const System::WideString AName, Qimport3xmlsax::TQIXMLNodeAction Action);
	void __fastcall SetCurrentSheet(TXlsxWorkSheet* const Value);
	
protected:
	System::Widestrings::TWideStrings* FSharedStrings;
	virtual void __fastcall LoadSheet(System::WideString SheetFile, int Id);
	virtual System::Variant __fastcall GetCellValue(const PXMLCType XlsxCell);
	virtual void __fastcall DoLoad();
	virtual Qimport3xmlbased::TXMLSheetList* __fastcall CreateSheets();
	virtual void __fastcall LoadSheets();
	virtual void __fastcall OnGetCellText(Qimport3xmlsax::TQIXMLStreamProcessor* Sender, const System::WideString Text, Qimport3xmlsax::TQIXMLTextType TextType);
	virtual void __fastcall OnLoadSheet(Qimport3xmlsax::TQIXMLStreamProcessor* Sender, const System::WideString AName, Qimport3xmlsax::TQIXMLNodeAction Action);
	__property TXlsxWorkSheet* CurrentSheet = {read=GetCurrentSheet, write=SetCurrentSheet};
	__property TXlsxCell* CurrentCell = {read=GetCurrentCell};
	
public:
	__fastcall virtual TXlsxWorkbook();
	__fastcall virtual ~TXlsxWorkbook();
	__property TXlsxWorkSheetList* WorkSheets = {read=GetSheets};
	__property bool LoadHiddenSheets = {read=FLoadHiddenSheets, write=FLoadHiddenSheets, nodefault};
	__property bool NeedFillMerge = {read=FNeedFillMerge, write=FNeedFillMerge, nodefault};
	__property int ImportRecCount = {read=FImportRecCount, write=FImportRecCount, nodefault};
};


class PASCALIMPLEMENTATION TXlsxDirectReadWorkbook : public TXlsxWorkbook
{
	typedef TXlsxWorkbook inherited;
	
protected:
	virtual void __fastcall LoadSheet(System::WideString SheetFile, int Id);
	
public:
	virtual System::Variant __fastcall GetCellValue(const PXMLCType XlsxCell);
	void __fastcall FreeSharedStrings();
public:
	/* TXlsxWorkbook.Create */ inline __fastcall virtual TXlsxDirectReadWorkbook() : TXlsxWorkbook() { }
	/* TXlsxWorkbook.Destroy */ inline __fastcall virtual ~TXlsxDirectReadWorkbook() { }
	
};


class PASCALIMPLEMENTATION TXlsxFile : public Qimport3xmlbased::TZipDocumentFile
{
	typedef Qimport3xmlbased::TZipDocumentFile inherited;
	
private:
	TXlsxWorkbook* __fastcall GetWorkbook();
	
protected:
	virtual Qimport3xmlbased::TXMLDocContainer* __fastcall CreateContainer();
	
public:
	__property TXlsxWorkbook* Workbook = {read=GetWorkbook};
public:
	/* TZipDocumentFile.Create */ inline __fastcall virtual TXlsxFile() : Qimport3xmlbased::TZipDocumentFile() { }
	/* TZipDocumentFile.Destroy */ inline __fastcall virtual ~TXlsxFile() { }
	
};


class PASCALIMPLEMENTATION TXlsxDirectReadFile : public TXlsxFile
{
	typedef TXlsxFile inherited;
	
protected:
	virtual void __fastcall DoAfterLoad();
	virtual Qimport3xmlbased::TXMLDocContainer* __fastcall CreateContainer();
	
public:
	__property System::WideString DocFolder = {read=FCurrFolder};
public:
	/* TZipDocumentFile.Create */ inline __fastcall virtual TXlsxDirectReadFile() : TXlsxFile() { }
	/* TZipDocumentFile.Destroy */ inline __fastcall virtual ~TXlsxDirectReadFile() { }
	
};


class PASCALIMPLEMENTATION TXlsxWorksheetReader : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	System::WideString FTmpDocFolder;
	Qimport3xmlsax::TQIDirectReadParser* FSAXParser;
	System::UnicodeString FWorksheetFileName;
	System::UnicodeString FParserResult;
	TXMLCType *FCurrentValue;
	TXlsxDirectReadWorkbook* FXlsxWorkbook;
	int FCurrentCol;
	int FCurrentRow;
	System::Variant FCellValue;
	bool FCellValueExtracted;
	bool FEof;
	void __fastcall ReopenWorksheet(const System::UnicodeString WorksheetFileName);
	void __fastcall DeleteTmpDocFolder();
	System::WideString __fastcall GetDataCell(int Col, int Row);
	bool __fastcall DataAvailable(int Col, int Row, System::WideString &CellValue);
	
public:
	__fastcall TXlsxWorksheetReader(const System::UnicodeString TmpDocFolder);
	__fastcall virtual ~TXlsxWorksheetReader();
	void __fastcall OpenWorkSheet(TXlsxWorkbook* const XlsxWorkbook, const System::UnicodeString WorksheetFileName);
	void __fastcall OnLoadCell(Qimport3xmlsax::TQIXMLStreamProcessor* Sender, const System::WideString AName, Qimport3xmlsax::TQIXMLNodeAction Action);
	void __fastcall OnGetCellText(Qimport3xmlsax::TQIXMLStreamProcessor* Sender, const System::WideString Text, Qimport3xmlsax::TQIXMLTextType TextType);
	__property System::WideString Cell[int Col][int Row] = {read=GetDataCell};
	__property bool Eof = {read=FEof, nodefault};
};


typedef System::DynamicArray<System::WideString> TXlsxTempRowData;

class PASCALIMPLEMENTATION TQImport3Xlsx : public Qimport3xmlbased::TQImport3WorkbookBased
{
	typedef Qimport3xmlbased::TQImport3WorkbookBased inherited;
	
private:
	TXlsxWorksheetReader* FWorksheetReader;
	System::UnicodeString FSheetName;
	bool FLoadHiddenSheet;
	bool FNeedFillMerge;
	Qimport3xlsxmapparser::TXlsxMapParserItems* FMapParserRows;
	bool FEndImportFlag;
	int FCurrentRow;
	int FCurrentCol;
	TXlsxTempRowData FTempRowData;
	HIDESBASE void __fastcall SetSheetName(const System::UnicodeString Value);
	void __fastcall SetLoadHiddenSheet(const bool Value);
	void __fastcall SetNeedFillMerge(const bool Value);
	void __fastcall ParseMap();
	
protected:
	virtual void __fastcall DoBeforeImport();
	virtual void __fastcall DoAfterImport();
	virtual bool __fastcall CheckCondition();
	virtual void __fastcall FillImportRow();
	virtual Qimport3::TQImportResult __fastcall ImportData();
	virtual void __fastcall DoLoadConfiguration(System::Inifiles::TIniFile* IniFile);
	virtual void __fastcall DoSaveConfiguration(System::Inifiles::TIniFile* IniFile);
	virtual void __fastcall DoUserDefinedImport();
	virtual bool __fastcall AllowImportRowComplete();
	virtual Qimport3basedocumentfile::TBaseDocumentFile* __fastcall CreateDocFile();
	virtual void __fastcall LoadDocFile();
	
public:
	__fastcall virtual TQImport3Xlsx(System::Classes::TComponent* AOwner);
	__fastcall virtual ~TQImport3Xlsx();
	
__published:
	__property FileName = {default=0};
	__property SkipFirstRows = {default=0};
	__property SkipFirstCols = {default=0};
	__property System::UnicodeString SheetName = {read=FSheetName, write=SetSheetName};
	__property bool LoadHiddenSheet = {read=FLoadHiddenSheet, write=SetLoadHiddenSheet, default=0};
	__property bool NeedFillMerge = {read=FNeedFillMerge, write=SetNeedFillMerge, default=0};
};


//-- var, const, procedure ---------------------------------------------------
}	/* namespace Qimport3xlsx */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_QIMPORT3XLSX)
using namespace Qimport3xlsx;
#endif
#pragma pack(pop)
#pragma option pop

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// Qimport3xlsxHPP
